This article is Part 2 in a series of cheat-sheets on the command line shell, bash. (Previous Page | Next Page)
Recall last ten commands from history:
$ history 10
Execute command from history with value of xxx:
$ !xxx
Execute last command from history:
$ !!
Open historical command xxx in text editor:
$ fc xxx
? (Matches any one character)* (Matches any number of characters)< (Directs contents of file to a command)> (Directs command output to a file)2> (Directs error from command to a file)&> (Directs command output and errors to a file)ยป (Directs output to file, appending it to the end of file)| (Pipes output of previous command to input of next command); (Sequentially executes next command)& (Runs command in background)$ (For expanding variables, substitutions, and expressions)$( ) (Command substitutions)$[ ] (Arithmetic expressions)
Executes pwd followed by ls:
$ pwd ; ls
Executes commands in new child shell:
$ (pwd ; ls)
Sorts passwd and opens the results in less:
$ cat /etc/passwd | sort | less
Untars file in background:
$ tar -xvf file &
Expands variable TEST:
$ echo $TEST
Search for all files in /home containing test in filename and open them in vi:
$ vi $(find /home | grep test)
Example of arithmetic expression:
$ echo "$[2000 - 1500]"
| This article is part of a series on Command Line | |
|---|---|
| bash: | Overview - Getting Started - Shortcuts & Piping - Managing Processes - Users & Permissions - Files & Archives - Customization |
| Other *nix & MacOS: | zsh |
| Windows: | PowerShell |