The shell is unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …).

learn more… | top users | synonyms (1)

0
votes
0answers
89 views

How do you open Wireshark's Legacy (GTK) By Default?

I've recently updated Wireshark on OSX El Capitan from 1.12.0 to 2.0.0. The newer stable release uses the Qt interface instead of the old X11 but the new UI is a lot buggy for me and I want the old ...
3
votes
1answer
68 views

Shell function to check if there is a suspended process that's a child of this shell?

I'd like to add an indicator to my PS1, showing whether there is a process suspended with ctrl+z. In order to do so, I'll need a function that is able to check for this situation. I'm not even sure ...
0
votes
0answers
26 views

Set a ZSH shell variable using mintty?

I have configuration files that I use to make my PS1 fancy. The design depends on the presence of a particular font. If the font isn't present, the PS1 looks ugly. I share access to a webmaster ssh ...
1
vote
1answer
26 views

How to programatically disconnect a ssh user?

I need to force a disconnect all sessions for a given user. Since this user might be root as well I think it would be better to avoid killing the parent sshd process along the way. Is there a ...
3
votes
2answers
81 views

Passing paths with spaces as arguments

I am having difficulty in passing some string variables having spaces in them as arguments to a program. For debugging and showing the arguments being passed, I created a demo Python script -: ...
2
votes
1answer
30 views

tools for coloring command line output of “dict”?

is there an existing solution somewhere to color the output of dict to improve its readability? I know i could manually color the output using tput, but i hope for a better solution. (i don't want ...
48
votes
6answers
3k views

Is there any reason to have a shebang pointing at /bin/sh rather than /bin/bash?

In most shell scripts I've seen (besides ones I haven't written myself), I noticed that the shebang is set to #!/bin/sh. This doesn't really surprise me on older scripts, but it's there on fairly new ...
0
votes
0answers
26 views

Shell ( := :- characters ) [duplicate]

I just started learnning shell script. The following snippet of code makes me wonder what does the symbols := and :- mean in line 4. while read perms links owner group size month day time file do ...
2
votes
1answer
61 views

bash: if / elif / fi gets not evaluated properly

I've got a script which checks for a specific PNG file in three directories. The first one is local and gets checked first. The second one is a remote share and gets checked only if the file is not ...
5
votes
1answer
173 views

Does POSIX sh allow empty compound-list in first condition and empty condition in case conditional construct?

Reading POSIX specification for case conditional construct, I see: case word in [(]pattern1) compound-list;; [[(]pattern[ | pattern] ... ) compound-list;;] ... [[(]pattern[ | pattern] ... ...
1
vote
1answer
32 views

Run for loop via ssh

Good day All, I'm attempting to run a for loop via SSH. The loop is used to get the last login of each user that has an account on the server, ssh 172.20.2.1 '''for i in `cat /etc/passwd | awk -F: ...
0
votes
0answers
17 views

How to make versions consistent

I'm using OS X 10.10, and IIRC I've installed bash and other GNU utilities using brew. The output of which bash is /usr/local/bin/bash, and it's version is 4.3, however the env variable SHELL points ...
-1
votes
1answer
64 views

bash - sed: -e expression #1, char 15: unterminated `s' command

I try to use sed command inside a loop to replace IP address, but it is always giving me this error: sed: -e expression #1, char 15: unterminateds' command` even it is not missing the end slash. ...
1
vote
1answer
32 views

find: missing argument to « -ok » [closed]

A while ago, I ran chmod to change some file permissions to 777. A friend of mine told me to never chmod 777, so I decided to change the permissions again. So, first I looked for all the 777 files: ...
0
votes
1answer
33 views

Tar files in order

I am taring files using this script tar -cvf test.tar -C /home/user/Desktop/filestoTar File_one zap_file tar -rvf test.tar -C /home/user/Downloads/test Auto_file rocket_file And I want to untar ...
1
vote
1answer
48 views

find command match issue [duplicate]

I'm having some trouble while searching files with find command and the way it handles the search. Let's say I'm currently in the directory /tmp and the directory contains the files: ...
10
votes
2answers
709 views

Is there a POSIX way of setting zeroth argument of a target application?

In bash you can use exec -a and in zsh you can alterntavely set ARGV0 to execute a program with a certain zeroth argument but is there also a POSIX way of doing so? As suggested in this one comment ...
1
vote
1answer
21 views

How to run shell script in crontab?

I have a file named restart.sh. The file contains 3 lines like: echo 'HI' service wildfly restart echo 'Hello' When I execute this as > sh /bin/restart.sh it works fine. When I execute this ...
0
votes
1answer
68 views

string fill performance in shell scripts: what is the best amount and for what shell?

I was trying to determine the best performance for string fill like in: str+="A" #one per loop I came with this script for bash: #!/bin/bash bReport=false nLimit=${1-3000}; #up to 25000 echo ...
0
votes
2answers
42 views

Remove both lines if column A values are repeated in next row

My input is like this: pak_c35079_g1_i1|m.14890 Pfam pak_c20797_g1_i1|m.3458 ProDom pak_c20797_g1_i1|m.3458 Pfam pak_c28265_g1_i3|m.9595 TIGRFAM pak_c28265_g1_i3|m.9595 ...
1
vote
2answers
47 views

Invoking a script with sudo ignores the shebang

Invoking a script using sudo ignores the shebang and runs the script in a different shell. To test, I created a script (test.sh) containing: #/bin/bash echo "BASH is: $BASH" echo "actual shell is: ...
3
votes
2answers
99 views

How can I submit the input filename into find exec correctly?

I want to create two pdf output files of a single LaTeX source. One output file is public and the other one (with further information) is becomes public. I use a make file which uses find to grep ...
4
votes
1answer
88 views

How the terminal can run programs and show its output? [closed]

I'm slowly creating a mental model of how linux works, and I've tried to simplify the most, my model of how linux works. Let's assume that the kernel boots and inits the only software it's gonna run: ...
1
vote
1answer
19 views

Openssl generate invalid websocket security code

I need to write websocket server on GAWK. And server must handle user's Sec-WebSocket-Key by following algorithm (from RFC): Concat key with 258EAFA5-E914-47DA-95CA-C5AB0DC85B11 Take sha-1 in binary ...
2
votes
2answers
30 views

Exported variables inside ssh session are empty

I am trying to export a variable inside a ssh session and reference the variable in the next write command. sshpass -p "password" ssh -t -t my-box <<EOF export newUrl="this is a url" sudo ...
1
vote
2answers
23 views

View current user process ancestors and formating the output

I'm using ps -eo ppid,pid,cmd to view all process, and how can I format the output to view like below? Only given PID and its ancestor will print (until init). 23464 current | 23211 bash | ...
4
votes
0answers
51 views

How to track an alias definition in Bash? [duplicate]

This is an alias defined in my Linux shell: $ alias vi alias vi='vim' This alias is so stupid that I want to delete it definitely. Is there a command to find where alias vi='vim' might have been ...
2
votes
1answer
61 views

Shell Script Loop Conditionally

I just create a new shell script and having trouble with small issue. Below is my script :- function mainMenu(){ while : do echo -e "\nMain Menu:" echo " A. Process Managements ...
-3
votes
1answer
38 views

shell script to sleep at an increment of 10 [closed]

shell script to sleep at an increment of 10 lines. I want my script to sleep for 3 mins after every 10 lines its read. then pick up from the last line. I'm not good with script, so I dunno where ...
0
votes
3answers
35 views

How to add two variables passed in the shell which returns integer count?

In my script I am using 2 variables: integer CCD_COUNT1= `grep '.CCD' $TMP_RPT_FILE1 | wc-l` It returns integer value suppose 47. Another variable: integer CCD_COUNT=`grep '.CCD' $TMP_RPT_FILE | ...
5
votes
2answers
299 views

Running remote command with ssh getting “bash: /dev/fd/63: No such file or directory”

I have /root/test.sh on a remote server, which has the following content: #!/bin/bash date On the remote server, I get the following output: # ./test.sh Fri Dec 18 07:41:10 EST 2015 # bash ...
3
votes
3answers
19 views

jump to current day's directory in a date based directory hierachy?

I have a pretty standard directory higherachy, year, month, date, for log files. If I want to go to todays logs I have to type cd logs/2015/12/16/ By itself this wouldn't be bad, but since I ...
5
votes
3answers
646 views

File name beginning with - (dash) [duplicate]

I have file called -l in my directory now I tried to do for i in *; do stat -c "%s %n" "$i"; done it lists all files with sizes but in the middle of the output there is something like 395 ...
0
votes
3answers
36 views

Matching lines in two files [duplicate]

Let's say I have two files, file1 and file2. file1: passd:xxx hopla:alli gnar:gungg araf:utap file2: alli utap How can i check what lines/words from file2 match file? Indeed I could probably do ...
6
votes
3answers
519 views

Meaning of [ “${1:0:1}” = '-' ]

I have the following script to launch a MySQL process: if [ "${1:0:1}" = '-' ]; then set -- mysqld_safe "$@" fi if [ "$1" = 'mysqld_safe' ]; then DATADIR="/var/lib/mysql" ... What does ...
0
votes
0answers
29 views

How to run a BBMap software .sh script in a for loop for a set of 100 .fasta files?

cd /home/user/Documents/bbmap ./bbmap.sh ref=fake.fa # indexes fasta format file sets ref filelist="fastaone.fasta, fastatwo.fasta, fastathree.fasta" for list in "$filelist" do ./bbmap.sh done Is ...
16
votes
4answers
714 views

How to trick a command into thinking its output is going to a terminal

Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed ...
3
votes
5answers
72 views

How to process special characters in in file name using find

I am to find all files that start with certail char , e.g find . -maxdepth 1 \( -name "^m*" -a ! -name "g$" \) -print but what if someone create file that has special characters in the name of that ...
2
votes
2answers
56 views

“cut” hangs when using “tail -f” in combination with “tr”

I'm try to pipe chat log files to some speech output, and want to remove timestamps with cut and remove special characters with tr. Unfortunately, cut seems to halt when using it with tail -f in ...
0
votes
0answers
38 views

How to minify Javascript and CSS with command-line using minify tool?

I'm not that versed in unix and I cannot have Java, so YUI Compressor does not apply, but I have this known Minify tool, which will get a minified version of a JS/CSS file from a specific URI ...
1
vote
2answers
148 views

cat command is not working inside shell script

I have the following line which is not working in ksh but works fine in sh cat `find /home/peter/databases -name "cells.txt"` This is working if this line is inside /usr/bin/sh script. But not when ...
0
votes
1answer
29 views

What is happening behind the scenes for these basic Unix commands?

I was just playing with some basic Unix commands with following operations create a file 'one' create a link 'two' to 'one' (ln one two) Edit the file 'one' and put words - one, two, three, four on ...
1
vote
2answers
14 views

Find doesn't work with recursion?

I ran the command below and notice it will only did the mod on the first level(SubDir*) on the finding and not the subsequence (ChildSubDir*). I wanted to ask if it is possible to go recursion on the ...
1
vote
1answer
20 views

Keep \ in read variable to show space [duplicate]

Trying to keep spaces in the variable for read with the \. $ echo "Drag folder to be copied to terminal and press ENTER." $ read FILE /Users/UserName/Desktop/Folder\ With\ Spaces\ In\ it $ echo ...
2
votes
2answers
117 views

gunzip from stdin

I have a large collection of gz files. I want to extract them all. Here is what I was trying to do: find . | grep .gz | gunzip However, gunzip does not accept list of files from stdinput. How can I ...
1
vote
1answer
32 views

A command that takes a single numeric argument and prints out the day of the week based on the formula

days=('Sunday''Monday') days=('Tuesday''Wednesday') days=('Thursday''Friday') days=('Saturday') for numbers in "S@"; do if [ $numbers -ge 0 ]; then result=$(($numbers ...
0
votes
1answer
43 views

Run git command to save output but consume STDERR too

I've tried: status=$(git status -s ./$name>&1) status=$(git status -s ./$name >2 /dev/null >&1) status=$(git status -s ./$name >2 /dev/null) status=$(git status -s ./$name > ...
3
votes
2answers
56 views

Changing file permissions according to their names

I created 512 files, with names made from combinations of permisions (r, w, x). I created them like this: touch ./{r,-}{w,-}{x,-}{r,-}{w,-}{x,-}{r,-}{w,-}{x,-} and I want the files to have same ...
1
vote
1answer
33 views

Assign path to variable which does not exist

In an effort of keeping things DRY, I am trying to assign a path to a variable that may not exist and have the following script which returns: /apps/tmp: No such file or directory #!/bin/bash ...
0
votes
1answer
63 views

shell find -delete “directory not empty” [duplicate]

i try to delete backupfiles on my synology nas older than 30 days, the files are in a directory which is created durig downoad the backupfile from my webserver after download i want to check -mtime ...