Bash Commands
Resources
Quizzes
- Folder hierarchy concepts (ls, cd, .., ~, /)
- Basic text manipulation
- File manipulation
- Output direction (>, < |)
- Utils
- More Text manipulation (sort, uniq, nl)
- Processes
- Remote
- Sed
- Grep
- Awk
- rsync
- Scripting
Filename aliasing
- * match 0 or more characters
- ? match any single character
- [abc...] match any enclosed character, hyphen to specify range
- [!abc...] not any character
- ~ home directory of current user
- (a|b) pattern a or b
- f{oo,u}bar generates foobar or fubar
- echo {1...10} will list numbers 1 through 10
- quoting
- ": $, ' ", \
- ': only '
Command Forms
- cmd & - execute in background
- cmd1 ; cmd2 - execute multiple commands
- {cmd1; cmd2;} execute commands as a group in the current shell
- (cmd2; cmd2) execute commands as a group in a subshell (I don't know what this means)
- cmd1 | cmd2 pipe output from cmd2 as intput to cmd 2
- cmd1 `cmd2` use cmd2 output as arguments to cmd1
- cmd > file send output to file and overwrite
- cmd &> file send output and errors to file and overwrite
- cmd >> file send output to file and append
- cmd < file take input for cmd from file
- (date; ls) > file - All output is sent to the file
- cmd | tee files send to standard out and files
Command History
- !! previous command
- !n command n
- !-n command n ago
- !string most recent command that starts with stirng
- !?string[?] most recent command that contains string
Terminal Commands
- cd
- pwd
Special Operations
- <
- >
- |
- >>
- tee
- .
- !!
- -
- ~, /
- ..
Control Characters (all are ctrl+
- A: beginning of line
- C: terminate foreground job
- E: end of line
- R: Backward search in history for text in command
- W: Erase backwards to whitespace
- Z: Pauses foreground job
Text Processing
- tr [options] set1 [set2]
- alnul, alpha, blank, digit, space, upper
- lower to upper "tr a-z A-Z"
- -d: delete, -s:squeeze(repeats the operation until no changes occur), -cs
- uniq
- unique a file by line
- -c: print the number of times each line occurred
- -i: ignore case
- -d: print only duplicated lines
- -u: print only unique lines
- -w N: check only N characters
- sort
- wc
- fold
- nl
- diff
Other
- ls
- less
- cat, tac
- man
- head
- tail
- bc
- rev
- echo
- -n: Do not print the trailing newline
- mapfile
Power Tools
- sed
- grep
- rsync
Files and Folders
- mv
- rm
- mkdir
- cp
- rmdir
- chmod
- ln
Utils
- cal
- date
- find
- gzip
- tar
- time
Remote
- ssh
- screen
- ftp
- ping
- rcp
- scp
- wget
Processes
- bg
- fg
- jobs
- kill
- ps
- coproc
Scripting
- if
- wait
- case