My Favorite And Frequently Used:
List contents of tar.gz file
tar -tzf filename.tar.gz
will match line containing S1 OR S2 OR S3 OR S4
grep 'S1.*S2.*S3.*S4' file
Lists all subdirectories of current directory
ls -d */
Total size of directory
du -sh
find a date:
TIMESTAMP=date '+%y%m%d%H%M'
move process from foreground to background
Ctrl-z and then bg
Entire word to uppercase
echo "word" | awk '{print toupper($0)}'
Checks equality between numbers
x -eq y Check is x is equal to y
x -ne y Check if x is not equal to y
x -gt y Check if x is greater than y
x -lt y Check if x is less than y
Checks equality between strings
x = y Check if x is the same as y
x != y Check if x is not the same as y
-n x Evaluates to true if x is not null
-z x Evaluates to true if x is null
Command Line Parameters for ' test '
-d check if the file is a directory
-e check if the file exists
-f check if the file is a regular file
-g check if the file has SGID permissions
-r check if the file is readable
-s check if the file's size is not 0
-u check if the file has SUID permissions
-w check if the file is writetable
-x check if the file is executable
print first field of the last line"
awk '{ field = $1 }; END{ print field }'
important build in variables
$# Number of command line arguments. Useful to test no. of command line args in shell script.
$* All arguments to shell
$@ Same as above
$- Option supplied to shell
$$ PID of shell
$! PID of last started background process (started with &)