UNIX / Linux Shell Scripting Tutorial

Unix / Linux Bourne / Bash shell scripting book Buy this book as a 75-page PDF document.
Read the sample. All the content, available offline, with examples, no adverts, and convenient to print.

UNIX/Linux Shell CheatSheet : free A4 PDF (52Kb) | PNG (90Kb)

Unix / Linux Shell Scripting Tutorial

14. Hints and Tips 1. Intro 2. Philosophy 3. A First Script 4. Variables - Part I 5. Wildcards 6. Escape Characters 7. Loops 8. Test 9. Case 10. Variables - Part II 11. Variables - Part III 12. External Programs 13. Functions 14. Hints and Tips 15. Quick Reference 16. Interactive 17. Exercises 16. Interactive

15. Quick Reference

This is a quick reference guide to the meaning of some of the less easily guessed commands and codes.
CommandDescriptionExample
&Run the previous command in the backgroundls &
&&Logical ANDif [ "$foo" -ge "0" ] && [ "$foo" -le "9"]
||Logical ORif [ "$foo" -lt "0" ] || [ "$foo" -gt "9" ] (not in Bourne shell)
^Start of linegrep "^foo"
$End of linegrep "foo$"
=String equality (cf. -eq)if [ "$foo" = "bar" ]
!Logical NOTif [ "$foo" != "bar" ]
$$PID of current shellecho "my PID = $$"
$!PID of last background commandls & echo "PID of ls = $!"
$?exit status of last commandls ; echo "ls returned code $?"
$0Name of current command (as called)echo "I am $0"
$1Name of current command's first parameterecho "My first argument is $1"
$9Name of current command's ninth parameterecho "My ninth argument is $9"
$@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 $*"
-eqNumeric Equalityif [ "$foo" -eq "9" ]
-neNumeric Inqualityif [ "$foo" -ne "9" ]
-ltLess Thanif [ "$foo" -lt "9" ]
-leLess Than or Equalif [ "$foo" -le "9" ]
-gtGreater Thanif [ "$foo" -gt "9" ]
-geGreater Than or Equalif [ "$foo" -ge "9" ]
-zString is zero lengthif [ -z "$foo" ]
-nString is not zero lengthif [ -n "$foo" ]
-ntNewer Thanif [ "$file1" -nt "$file2" ]
-dIs a Directoryif [ -d /bin ]
-fIs a Fileif [ -f /bin/ls ]
-rIs a readable fileif [ -r /bin/ls ]
-wIs a writable fileif [ -w /bin/ls ]
-xIs an executable fileif [ -x /bin/ls ]
parenthesis:
( ... )
Function definitionfunction myfunc() { echo hello }

14. Hints and Tips 1. Intro 2. Philosophy 3. A First Script 4. Variables - Part I 5. Wildcards 6. Escape Characters 7. Loops 8. Test 9. Case 10. Variables - Part II 11. Variables - Part III 12. External Programs 13. Functions 14. Hints and Tips 15. Quick Reference 16. Interactive 17. Exercises 16. Interactive
Suggested books: Recommended Reading
StumbleUponStumbleUpon | del.icio.usdel.icio.us

Site Links



1. Intro
2. Philosophy
3. A First Script
4. Variables - Part I
5. Wildcards
6. Escape Characters
7. Loops
8. Test
9. Case
10. Variables - Part II
11. Variables - Part III
12. External Programs
13. Functions
14. Hints and Tips
15. Quick Reference
16. Interactive
17. Exercises
18. Forum
19. Recommended Books




My blog has tips about how to use Unix and Linux commands XML



contact