Everything that can be useful in test constructs (if statements) in a bash environment.
This cheat sheet is based on the Advanced Bash-Scripting Guide by Mendel Cooper.
Man command Show manual for command Bash Shortcuts CTRL-c Stop current command CTRL-z Sleep program CTRL-a Go to start of line CTRL-e Go to end of line CTRL-u Cut from start of line CTRL-k Cut to end of line CTRL-r Search history!! Repeat last command!abc Run last command starting with abc!abc:p Print last command starting with abc. Basic Linux commands. Description ls Lists all files and directories in the present working directory. This cheatcheat will help you to improve your skills in bash, There are 2 columns, the left one is the command in parenthesis ex (C-j) = Ctrl + j and the right one will do a simple description. The Notes Section could help to resolve some problems or include features into your Terminal. This Bash cheat sheet contains commands to help you with the following types of tasks: History. File and navigation. Keyboard shortcuts. Running commands in sequence. To download this cheat sheet, log in or enter your email address and country below.
| Similar to |
| Similar to |
|
|
|
|
|
|
|
|
|
|
|
|
| (within double parentheses)
|
| (within double parentheses)
|
| (within double parentheses)
|
| (within double parentheses)
|
| The comparison operator behaves differently within a double-brackets test than within single brackets. |
| This operator uses pattern matching within a [[ ... ]] construct. |
| Note that the |
| Note that the |
| that is, has zero length |
|
|
|
| file is a regular file (not a directory or device file) |
| file is a directory |
| file is a symbolic link |
| file is a block device |
| file is a character device |
| file is a pipe |
| file is a socket |
| file is not zero size |
| file (descriptor) is associated with a terminal device This test option may be used to check whether the |
| file has read permission (for the user running the test) |
| file has write permission (for the user running the test) |
| file has execute permission (for the user running the test) |
| set-group-id (sgid) flag set on file or directory |
| set-user-id (suid) flag set on file |
| sticky bit set |
| you are owner of file |
| group-id of file same as yours |
| file modified since it was last read |
| file f1 is newer than f2 |
| file f1 is older than f2 |
| files f1 and f2 are hard links to the same file |
| 'not' -- reverses the sense of the tests above (returns true if condition absent). |
Based on the Advanced Bash-Scripting Guide by Mendel Cooper.