This shows you the differences between two versions of the page.
bash:quick_reference [2015/07/09 15:51] 217.110.111.101 added some other checks for bash |
bash:quick_reference [2024/02/16 00:48] (current) |
||
---|---|---|---|
Line 17: | Line 17: | ||
|$@ |All of current command's parameters (preserving whitespace and quoting) |echo "My arguments are $@" | | |$@ |All of current command's parameters (preserving whitespace and quoting) |echo "My arguments are $@" | | ||
|$* |All of current command's parameters (not preserving whitespace and quoting) |echo "My arguments are $*" | | |$* |All of current command's parameters (not preserving whitespace and quoting) |echo "My arguments are $*" | | ||
- | |-eq |Numeric Equality |if [ "$foo" -eq "9" ] | | + | |parenthesis: ( ... ) |Function definition |function myfunc() { echo hello }| |
- | |-ne |Numeric Inquality |if [ "$foo" -ne "9" ] | | + | |
- | |-lt |Less Than |if [ "$foo" -lt "9" ] | | + | |
- | |-le |Less Than or Equal |if [ "$foo" -le "9" ] | | + | |
- | |-gt |Greater Than |if [ "$foo" -gt "9" ] | | + | |
- | |-ge |Greater Than or Equal |if [ "$foo" -ge "9" ] | | + | |
- | |-z |String is zero length |if [ -z "$foo" ] | | + | |
- | |-n |String is not zero length |if [ -n "$foo" ] | | + | |
- | |-nt |Newer Than |if [ "$file1" -nt "$file2" ] | | + | |
|-b |block special file |if [ -b filename ] | | |-b |block special file |if [ -b filename ] | | ||
|-c |Special character file|if [ -c filename ] | | |-c |Special character file|if [ -c filename ] | | ||
|-d |Is a Directory |if [ -d /bin ] | | |-d |Is a Directory |if [ -d /bin ] | | ||
- | |-f |Is a File |if [ -f /bin/ls ] | | ||
|-e |Is file exist |if [ -e /bin/ls ] | | |-e |Is file exist |if [ -e /bin/ls ] | | ||
- | |-r |Is a readable file |if [ -r /bin/ls ] | | + | |-eq |Numeric Equality |if [ "$foo" -eq "9" ] | |
+ | |-f |Is a File |if [ -f /bin/ls ] | | ||
|-G |check if file exists and is owned by effective groupid |if [ -G /bin/ls ] | | |-G |check if file exists and is owned by effective groupid |if [ -G /bin/ls ] | | ||
|-g |true if file exists and is set-group-id |if [ -g /bin/ls ] | | |-g |true if file exists and is set-group-id |if [ -g /bin/ls ] | | ||
+ | |-ge |Greater Than or Equal |if [ "$foo" -ge "9" ] | | ||
+ | |-gt |Greater Than |if [ "$foo" -gt "9" ] | | ||
|-k |check sticky bit |if [ -k /bin/ls ] | | |-k |check sticky bit |if [ -k /bin/ls ] | | ||
|-L |if file a symbolic link |if [ -L /etc/alternatives/editor ] | | |-L |if file a symbolic link |if [ -L /etc/alternatives/editor ] | | ||
+ | |-le |Less Than or Equal |if [ "$foo" -le "9" ] | | ||
+ | |-lt |Less Than |if [ "$foo" -lt "9" ] | | ||
+ | |-n |String is not zero length |if [ -n "$foo" ] | | ||
+ | |-ne |Not Equal |if [ "$foo" -ne "9" ] | | ||
+ | |-nt |Newer Than |if [ "$file1" -nt "$file2" ] | | ||
|-O |True if file exists and is owned by the effective user id |if [ -O file ] | | |-O |True if file exists and is owned by the effective user id |if [ -O file ] | | ||
- | |-S |if file is a socket |if [ -S file ] | | + | |-r |Is a readable file |if [ -r /bin/ls ] | |
|-s |if file is nonzero size |if [ -s /bin/ls ] | | |-s |if file is nonzero size |if [ -s /bin/ls ] | | ||
+ | |-S |if file is a socket |if [ -S file ] | | ||
+ | |-u |check if file set-user-id bit is set |if [ -u /bin/ls ] | | ||
|-w |Is a writable file |if [ -w /bin/ls ] | | |-w |Is a writable file |if [ -w /bin/ls ] | | ||
|-x |Is an executable file |if [ -x /bin/ls ] | | |-x |Is an executable file |if [ -x /bin/ls ] | | ||
- | |-u |check if file set-user-id bit is set |if [ -u /bin/ls ] | | + | |-z |String is zero length |if [ -z "$foo" ] | |
- | |parenthesis: ( ... ) |Function definition |function myfunc() { echo hello }| | + |