Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 21167

Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead. For shell scripts with errors/syntax errors, please check them with the shellcheck program (or in the web shellcheck server at https://shellcheck.net) before posting here.

4 votes

How can I use '*' to capture everything with exceptions

Use a case statement to weed out the exceptions, like this: for f in ${PROJECT}; do case "$f" in *[tsa]_1*) continue;; esac # ... actual work here ... done
zwol's user avatar
  • 7,509
10 votes

bash if not multiple conditions without subshell?

You're actually more likely to find /usr/bin/perl on a randomly selected Unix than you are bash. …
zwol's user avatar
  • 7,509
1 vote

Why is the 'if [ $1="1" ]' branch always selected even if $1 is not 1?

Bash is not universal (and if you don't need universal, why are you writing a shell script?) #! …
zwol's user avatar
  • 7,509
12 votes
Accepted

Using “reserved” codes for exit status of shell scripts

There have been several attempts to standardize the meanings of process exit codes. In addition to the one you mention, I know of: the BSDs have sysexits.h which defines meanings for values from 64 …
zwol's user avatar
  • 7,509
5 votes

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

Bash) then you can assume an interpreter for a better scripting language is installed. Perl, for instance, is more likely to be available than Bash is. Therefore, you should never write a #! … /bin/bash script, because if that's an option, a better language is also an option. 1 For instance, Solaris 10 and older shipped the original Bourne shell as /bin/sh. …
zwol's user avatar
  • 7,509
7 votes

How can I test if a variable is empty or contains only spaces?

The legacy /bin/sh is the only thing you can be certain you have, but Perl for instance is more likely to be available cross-platform than Bash. …
zwol's user avatar
  • 7,509
2 votes

Use #!/bin/sh or #!/bin/bash for Ubuntu-OSX compatibility and ease of use & POSIX

/bin/sh, because Bash is not guaranteed to be installed anywhere, let alone in /bin. It's actually much, much worse than that. … The basic Perl interpreter is more likely to be available than Bash. …
zwol's user avatar
  • 7,509
4 votes
Accepted

error ./c.sh: line 24: [: too many arguments in shell program

You are assuming that the output of who | grep jeevansai will be a single line, which is wrong. ++ who ++ grep jeevansai ++ cut -c 32-34 + ld='31 31 ' This is telling you that the command ld=`wh …
zwol's user avatar
  • 7,509
3 votes

How do ssh remote command line arguments get parsed

Supporting what the other answers have said, I looked up the code that invokes commands on the remote, https://github.com/openssh/openssh-portable/blob/4f29309c4cb19bcb1774931db84cacc414f17d29/session …
zwol's user avatar
  • 7,509