I spend one month to read it and cost two months to complete writing the abstract of the this book. This is the first book I write the abstract. I feel it's a best start. Haa
Chapter 1. Why Shell Programming?
The chapter answer why you need to grasp shell programming and answer when not to use shell scripts.
--------------------------------------------------------------
Chapter 2. Starting Off With a Sha-Bang
Start a file with a #!/XXX/XXX and make it executable.
#!/bin/sh
#!/bin/bash
#!/usr/bin/perl
#!/usr/bin/tcl
#!/bin/sed -f
#!/usr/awk -f
2.1. Invoking the script
1 make the script executable.
chmod 555 scriptname
chmod +rx scriptname
chmod u+rx scriptname
2 execute the shell script
./criptname arguments
---------------------------------------------------------------
Chapter 3. Exit and Exit Status
1 $? reads the exit status of the last command executed.$? is especially useful for testing the result of a command in a script.
Caution:
Certain exit status codes have reverved meanings and should not be user-specified in a script.
__________________________________________________________________
Chapter 4. Special Characters
1 Comments: #
eg: # This line is a comment.
but the first hash(#) in the next statement is not a comment.
echo ${PATH#*:} # Parameter substitution, not a comment.
Caution:
Certain pattern matching operations also use the #.
2 command separator: ;
eg: echo hello; echo there
3 Terminator in a case option: ;;[double semicolon]
eg: case "$variable" in
abc) echo "$variable = abc";;
xyz) echo "$variable = xyz";;
esac
3 dot command: .
1st: A dot is equivalent to source. This is a bash builtin.
2nd: In a regular expression, a dot matches a single character.
3rd: A dot is the filename prefilx of a "hidden" file, a file that an ls will not normally show.
4 patial quoting: "[double quote]
5 full quoting: '[single quote]
6 comma operator: ,
7 escap: /X
8 Filename path separator: /
9 command substitution: `
10 null command: :
11 reverse (or negate) the sense of a test or exit status: !
12 wild card: *
13 wild card(single character): ?
14 variable substitution: $
Caution:
In a regular expression, a $ matches the end of a line.
15 Parameter substitution: ${}
16 positional parameters: $*, $@
17 command group: ()
eg: (a=hello; echo $a)
18 brace expansion: {}
eg: grep linux file*.{txt, htm*}
# in the files "fileA.txt", "file2.txt", "fileR.html", "file-87.htm", etc.
18: block of code: {}
eg: bash$ {local a; a=123}
19 test: []
Test expression between[]. Note that [ is part of the shell builtin test, not a link to the external command /usr/bin/test.
20 test: [[]]
Test expression between [[]](shell keyword).
21 integer expansion: (())
Expand and evaluate integer expression between(()).
22 redirection: >>&>><
23 pipe: |
24 force redirection: >1
25 run job in background: &
26 redirection from/to stdin or stdout: -[dash]
27 previous working directory: - [dash]
28 Minus: -
29 Equals: =
30 Plus: +
31 modulo: %
32 home directory: ~
33 current working directory: ~+
34 previous working directory: ~-
35 Control Characters
Ctl-C: Terminate a foreground job.
Ctl-D: Log out from a shell(simial to exit or EOF)
Ctl-6: "BEL"(beep)
Ctl-H: Backspace
Ctl-J: Carriage return
Ctl-M: Newline
Ctl-U: Erase a line of input
Ctl-Z: Pause a foreground
36 Whitespace: functions as a separator, separating command or variables.
Note: $IFS, the special variable separating fields of input to certain commands, defaults to whitespace.
--------------------------------------------------------------------------
Chapter 5. Introduction to Variables and Parameters
5.1. Variable Substitution
$varialbe
5.2. Variable Assignment
=
5.3. Bash Variable Are Untyped
5.4. Special Variable Types
local variables: variables visible only within a code block or function
environmental variables: variables that affect the behavior of the shell and user interface
positional parameters: arguments passed to the script from the command line, such as $0, $1, $2, $3... 40 is the name of the script itself, $1 is the first argument, $2 the second, $3 the third and so on. After $9, the arguments must be enclosed in brackets, for exmple, ${10}, ${11}, ${12}
-----------------------------------------------------------------------------
Chapter 6. Quoting
""''
Caution: ``
-----------------------------------------------------------------------------
chapter 7. Tests
7.1. Test Constucts
[] [[]] (Started with version 2.02)
(()) expands and evaluates an arithmetic expression and similiar to "let".
7.2. File test operators
-e: file exists
-f: file is a regular file (not a directory or device file)
-s: file is not zero size
-d: file is a directory
-c: file is a character device (keyboard, modem, sound card, etc.)
-p: file is a pipe
-h: file is a symbolic link
-L: file is a symbolic link
-S: file is a socket
-t: file descritpor is associated with a terminal device
-r: file has read permission
-w: file has write permission
-x: file has execute permission
-g: set-group-id (sgid) flag set on file or directory
-u: set-user-id (suid) flag set on file
-k: sticky bitset
-O: you are owner of file
-G: group-id of file same as yours
-N: file modified since it was last read
f1 -nt f2: file f1 is new than f2
f1 -ot f2: file f1 is older than f2
f1 -ef 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).
7.3. Comparison operators (binary)
1 Integer comparison
-eq: is equal to
eg: if [ "$a" -eq "$b" ]
-ne: is not equal to
eg: if [ "$a" -new "$b" ]
-gt: is greater than
eg: if [ "$a" -gt "$b" ]
-ge: is greater than or equal to
eg: if [ "$a" -ge "$b" ]
-lt: is less than
eg: if [ "$a" -lt "$b" ]
-le: is less than or equal to
eg: if [ "$a" -le "$b" ]
<: is less than (within double parentheses)
eg: (("$a" < "$b"))
<=: is less than or equal to (within double parentheses)
eg: (("$a" <= "$b"))
>: is greater than (within double parentheses)
eg: (("$a" > "$b"))
>=: is greater than or equal to (within double parentheses)
eg: (("$a" >= "$b"))
2 string comparison
=: is equal to
eg: if [ "$a" = "$b" ]
==: is equal to
eg: if [ "$a" == "$b" ]
caution: this is a synonym for =.
!=: is not equal to
eg: if [ "$a" != "$b" ]
Note: this operator uses pattern matchin within a [[...]] construct
<: is less than, in ASCII alphabetical order
eg:
if [[ "$a" < "$b" ]]
if [ "$a" /< "$b" ]
>: is greater than, in ASCII alphabetical order
-z: stirng is "null", that is, has zero length
-n: string is not " null"
Caution: The -n test absolutely requires that the string be quoted within the test brackets. Using an unqutoed string with ! -z, or even just the unquoted string alone with test brackets normally works, however, this is an unsafe practice.
7.4. Nested if/then Condition Tests
if [ condition1 ]
then
if [ condition2 ]
then
do-something # But only if both "condition1" and "condition2" valid.
fi
fi
-----------------------------------------------------------------------------
Chapter 8. Operations and Related Topics
1 assignment
=: variable assignment
2 arithmetic operators
+: plus
-: minus
/: division
**: exponentiation
%: modulo, or mod (returns the remainder of an integer division operation)
+=: "plus-equal" (increment variable by a constant)
-=: "minus-equal" (decrement variable by a constant)
*=: "times-equal" (multiply variable by a constant)
/=: "slash-equal" (divide variable by a constant)
%=: "mod-equal" (remainder of dividing variable by a constant)
3 betwise operators
<<: bitwise left shift (multiplies by 2 for each shift position)
<<=: "left-shift-equal"
>>: bitwise right shift (divides by 2 for each shift position)
>>=: "right-shift-equal" (inverse of <<)
&: bitwise and
&=: "bitwise and-equal"
|: bitwise OR
|=: bitwise OR-equal
~: bitwise NOT
^: bitwise XOR
^=: bitwise XOR-equal
4 logical operators
&&: and (logical)
||: or (logical)
5 miscellaneous operators
,: comma operator
8.2. Numberical Constants
decimal, octal preceded by a 0 and hexadecimal preceded by 0x. A number with an embedded # is evaluated as BASE#NUMBER (this option is of limited usefulness because of range restrictions).
-----------------------------------------------------------------------------
Chapter 9. Variables Revisited
9.1. Internal Variables
1 Buitlin variables
$BASH
the path to the Bash binary itself, usually /bin/bash
$BASH_ENV
$BASH_VERSINFO[n]
$BASH_VERSION
$DIRSTACK
contents of the directory stack (affected by pushd and popd)
This builtin variable is the counterpart to the dirs command.
$EDITOR
the default editor invoked by the a script, usually vi or emacs.
$EUID
"effective" user id number
$FUNCNAME
name of the current function
$GLOBIGNORE
A list of filename patterns to be exclude from matching in globbing.
$GROUPS
groups current user belongs to
$HOME
home directory of the user, usually /home/username
$HOSTNAME
The hostname command assigns the system name at bootup in an init script.
$HOSTTYP
host type
$IFS
input field separator
$IGNOREEOF
ignore EOF: how many end-of-files (control-D) the shell will ignore before logging out.
$LC_COLLATE
$LC_COLLATE
$LINENO
This variable is the line number of the shell script in which this variable appears.
$MACHTYPE
machine type
$OLDPWD
old working directory ("OLD-print-working-dirctory", previous directory you were in)
$OSTYPE
operating system type
$PATH
path to binaries, usually /user/bin, /usr/X11R6/bin, /usr/local/bin, etc.
$PIPESTATUS
exit status of last executed pipe.
$PPID
The $PPID of a process is the process id (pid) of its parent process.
$PS1
This is the main prompt, seen at the command line.
$PS2
The secondary prompt, seen when additional input is expected. It is displays as ">".
$PS3
The tertiary prompt, displayed in a select loop
$PS4
The quartenary prompt, shown at the beginning of each line of output when invoking a script with the -x option.
$PWD
working directory (directory you are in at the time)
$REPLY
The default value when a variable is not supplied to read.
$SECONDS
The number of seconds the scipt has been running.
$SHELLOPTS
the list of enabled shell options, a readonly variable
$SHLVL
shell level, how deeply Bash is nested.
$TMOUT
If the $TMOUT environmental variable is set to a non-zero value time, then the shell prompt will time out after time seconds. This will cause a logout.
$UID
user id number
2 Postional Parameters
$0, $1, $2, etc.
positional parameters, passed from command line to script, passed to a function, or set to a variable
$#
number of command line arguments or positional parameters.
$*
All of the positional parameters, seen as a single word
$@
Same as $*, but each parameter is a quoted string, that is, the parameters are passed on intact, without interpreation or expansion. This means, among other things, that each parameter in the argument list is seen as a separate word.
3 Other Special Parameters
$-
Flags passed to script
$!
PID (process id) of last job run in background
$_
Special variable set to last argument of previous command executed.
$?
exit status of a command, function, or the script itself
$$
process id of cript, often used in scripts to construct temp file names.
9.2 Manipulating Strings
1 String Length
${#string}
expr length $string
expr "$string":'.*'
2 Length of Matching Substring at Beginning of String
expr match "$string" '$substring'
expr "$string":'$substring'
3 Index
expr index $string $substring
4 Substring Extraction
${string:position}
${string:position:length}
expr substr $string $position $length
expr match "$string"'/($subtring/)'
expr "$string":'/($substring/)'
5 Substring Removal
${string#substring}
Strips shortest match of $substring from front of $string.
${string##substring}
Strips longest match of $substring from front of $string.
${string%substring}
Strips shortest match of $substring from back of $string.
${string%%substring}
Strips longest match of $substring from back of $string.
6 Substring Replacement
${string/substring/replacement}
Replace first match of $substring with $replacement.
${string//substring/replacement}
Replace all matches of $substring with $replacement.
${string/#substring/replacement}
If $substring matches front end of $string, substitue $replacement for $substring.
${string/%substring/replacement}
If $substring matches back end of $string, substitue $replacement for $substring.
9.2.1 Manipulating strings using awk
9.3 Parameter Substitution
1 Manipulating and/or expanding variables
${parameter}
${parameter-default}
${parameter=default}, ${parameter:=default}
${parameter+alt_value}, ${parameter:+alt_value}
${paramter?err_msg}, ${parameter:?err_msg}
2 Variable length / Substring removal
${#var}
${var#pattern}, ${var##pattern}
${var%pattern}, ${var%%pattern}
3 Variable expansion / Substring replacement
${var:pos}
Variable var expanded, starting from offset pos.
${var:pos:len}
Expansion to a max of len characters of len characters of variable var, from offset pos.
${var/patt/replcaement}
Fisrt match of patt, within var replaced with replacement.
${var//patt/replacement}
Global replacment. All mathces ofpatt, within var replcaed with replacement.
${var/#patt/replacement}
If prefix of var matchs replacement, then substitue replacement for patt.
${var/%patt/replacement}
If suffix of var matches replacement, then substitute replacement for patt.
${var/%patt/replacement}
If suffix of var matches replacement, then substitute replcament f
${!varprefix*}, ${!varprefix@}
9.4. Typing variables: declare or typeset
1 declare/typeset options
-r readonly
-i integer
-a array
-f functions
-x export
var=$value
9.5. Indirect References to Variables
9.6. $RANDOM: generate random integer
9.7. The Double Parentheses Construct
Similar to the let command, the ((...)) construct permits arithmetic expansion and evaluation.
-----------------------------------------------------------------------------
Chapter 10. Loops and Branches
10.1. Loops
1 for loops
for arg in [list]
do
command
done
eg1:
for file in $(command1 | command2 | ...)
do
command
done
eg2:
for ((a=1; a<=24; a++))
do
echo $a
done
2 while
while [condition]
do
command
done
eg1:
LIMIT=24
a=1
while [ "$a" -le $LIMIT ]
do
echo $a
done
eg2:
LIMIT=24
a=1
while ((a <= LIMIT))
do
echo $a
done
3 until
until [conditon-is-true]
do
command
done
eg:
a=1
until [ "$a" = "25" ]
do
echo $a
((a++))
done
10.2. Nested Loops
10.3. Loop Control
break, continue
10.4. Testing and Branching
1 Controlling program flow in a code block
case "$variable" in
"$condition1")
command...
;;
"$conditon2")
command...
;;
esac
-----------------------------------------------------------------------------
Chapter 11. Internal commands and Builtins
1 jobs
Lists the jobs running in the background, giving the job number.
2 disown
Remove job(s) from the shell's table of active jobs.
3 fg, bg
The fg command switches a job running in the background into the foreground. The bg command restarts a suspended job, and runs it in the backround.
4 wait
Stop script execution until all jobs running in background have terminated, or until the job number or process id specified as an option terminates.
5 suspend
This has a similar effect to Control-Z, but it suspends the shell.
6 logout
Exit a login shell optionally specifying an exit status.
7 times
Gives statics on the system time used in executing commands.
8 kill
focibly terminate a process by sending it an appropriate terminate signal.
9 command
The command COMMAND directive disables aliaes and functions for the command "COMMAND".
10 builtin
Invoking builtin BUILTIN_COMMAND runs the command "BUILTIN_COMMAND" as a shelll builtin, temporarily disabling both functions and external system commands with the same name.
11 enable
This either enables or disables a shell builtin command.
12 autoload
This is a port to Bash of the ksh autoloader.
Table 11-1. Job Identifiers
Notation Meaning
%N Job number [N]
%S Invocation (command line) of job begin with string S
%?S Invocation (command line) of job contains within it string S
%% "current" job (last job stopped in foreground or started in background)
%+ "current" job (last job stopped in foreground or started in background)
%- "last job"
$! Last background process
----------------------------------------------------------------------------
Chapter 12. External Filters, Programs and Commands
12.1. Basic Commands
1 ls
The basic file "list" command.
2 cat, tac
cat, an acronym for concatenate, lists a file to stdout.
3 rev
reverses each line of a file, and outputs to stdout.
4 cp
This is the file copy command.
5 mv
This is the file move command.
6 rm
Delete (remove) a file or files.
7 rmdir
Remove directory.
8 mkdir
Make directory, creates a new directory.
9 chmod
Changes the attributes of an existing file.
10 chattr
Changes file attributes.
11 ln
Creates links to pre-existings files.
12.2. Complex commands
1 find
2 xargs
A filter for feeding arguments to a command, and also a tool for assembling the commands themselves.
3 expr
All-purpose expression evaluator: Concatenates and evaluates the arguments according to the operation given.
12.3. Time / Date Commands
1 date
Simply invoked, date prints the date and time to stdout.
2 zdump
Echoes the time in a specified time zone.
3 time
Outputs very verbose timing statistics for executing a command.
4 touch
Utitlity for updating access/modification times of a file to current system time or other specified time, but also useful for creating a new file.
5 at
The at job control command executes a given set of commands at a specified time.
6 batch
The batch job control command is similar to at, but it runs a command list when the system load drops below.
7 cal
Prints a neatly formatted monthly calendar to stdout.
8 sleep
This is the shell equivalent of a wait loop.
9 usleep
Miscrosleep (the "u" may be read as the Greek "mu", or micro prefix).
10 hwclock, clock
The hwclock command accesses or adjusts the machine's hardware clock.
12.4. Text Processing Commands
1 sort
File sorter, often used as a filter in a pipe.
2 tsort
Topological sort, reading in pairs of whitespace-separated strings and sorting according to input patterns.
3 diff, patch
diff: flexible file comparison utility.
patch: flexible versioning utility.
4 diff3
An extended version of diff that compares three files at a time.
5 sdiff
Compare and/or edit two files in order to merge them into an output file.
6 cmp
The cmp command is a simpler version or diff, above.
7 comm
Versatile file comparison utility.
8 uniq
This filter removes duplicate lines from a sorted file.
9 expand, unexpand
The expand filter converts tabs to spaces, It is oftern used in a pipe.
10 cut
A tool for extracting fields from files.
11 colrm
Column removal filter.
12 paste
Tool for merging together different files into a single, multi-column file.
13 join
Consider this a special-purpose cousin of paste.
14 head
lists the beginning of a file to stdout (the default is 10 lines, but this can be changed).
15 tail
lists the end of a file to stdout (the default is 10 lines).
16 grep
A multi-purpose file search tool that uses regular expressions.
17 look
The command look works like grep, but does a lookup on a "dictionary", a sorted word list.
18 sed, awk
Scripting languages especialy suited for parsing text files and command output.
19 wc
wc gives a "word count" on a file or I/O stream.
20 tr
character translation filter.
21 fold
A filter that wraps lines of input to a specified width.
22 fmt
Simple-minded file formatter, used as a filter in a pipe to "wrap" long lines of text output.
23 ptx
The ptx [targetfile] command outputs a permuted index (cross-reference list) of the targetfile.
24 column
column formatter. this filter transforms list-type text output into a "pretty-printed" table by inserting tabs at appropriate places.
25 nl
Line numbering filter.
26 pr
print formatting filter.
27 gettext
A GNU utility for localizatin and translating the text output of programs into foreign languages.
28 iconv
A utility for converting file(s) to a different encoding (character set).
29 recode
Consider this a fancier version of iconve, above.
30 groff, gs, TeX
Groff, Tex, and Postscript are text markup languages used for preparing copy for printing or formatted video display.
31 lex, yacc
The lex lexical analyzer produces programs for pattern matching.
The yacc utility creates a parser based on a set of specifications.
12.5. File and Archiving Commands
I Archiving
1 tar
The standard UNIX archiving utility.
2 shar
Shell archiving utility.
3 ar
Creation and manipulation utility for archives, mainly used for binary object file libraries.
4 cpio
This specialized archiving copy command (copy input and output ) is rarely seen any more, having been supplanted by tar/gzip.
II Compression
1 gzip
The standard GNU/UNIX compression utility, replacing the inferior and proprietary compress.
2 bzip2
An alternate compression utility, usually more efficient than gzip, especially on large files.
3 compress, uncompress
This is an older, proprietary compression utility found in commercial UNIX distributions.
4 sq
Yet another compression utility, a filter that works only on sorted ASCII word lists.
5 zip, unzip
Cross-platform file archiving and compression utility compatible with DOS PKZIP.
III File Information
1 file
A utility for identifying file types.
2 which
Which command-xxx gives the full path to "command-xxx".
3 whereis
Similar to which, above, whereis command-xxx gives the full path to "command-xxx", but also to its manpage.
4 whatis
whatis filexxx looks up "filexxx" in the whatis database.
5 vdir
Show a detailed directory listing.
6 shred
Securely erase a file by overwriting it multiple times with random bit patterns before deleting it.
7 locate, slocate
The locate command searches for files using a database stored for just that purpose.
8 strings
Use the strings command to find printable strings in a binary or data file.
IV Utilities
1 basename
Strips the path information from a file anme, printing only the file name.
2 dirname
Strips the basename from a filename, printing only the path information.
3 split
Utility for splitting a file into smaller chunks.
4 sum, cksum, md5sum
These are utilities for generating checksums.
V encoding and Encryption
1 uuencode
This utility encodes binary file into ASCII characters, making them suitable for transmission in the body of an e-mail messge or in a newsgroup posting.
2 uudecode
This reverses the encoding, decoding uuencoded files back into the original binaries.
3 crypt
At one time, this was the standard UNIX file encryption utility.
V Miscellaneous
1 make
Utility for building and compiling binary packages.
2 install
Special purpose file copying command, similar to cp, but capable of setting permissions and attributes of the copied files.
3 more, less
Pagers that display a text file or stream to stdout, one screenful at a time.
12.6. Communications Commands
I Information and Statistics
1 host
Searches for information about an internet host by name or IP address, using DNS.
2 vrfy
Verify an Internet e-mail address.
3 nslookup
Do an Internet "name server lookup" on a host by IP address.
4 dig
Similar to nslookup, do an Internet "name server lookup" on a host.
5 traceroute
Trace the route taken by packets sent to remote host.
6 ping
Broadcat an "ICMP ECHO_REQUEST" packet to other machines, either on a local or remote network.
7 whois
Perform a DNS (Domain Name System) lookup.
8 finger
Retrieve information about a partcular user on a network.
II Remote Host Access
1 sx, rx
The sx and rx command set serves to transfer files to and from a remote host using the xmodem protocol.
2 sz, rz
The sz and rz command set serves to transfer files to and from a remote host using the xmodem protocol.
3 ftp
Utility and protocol for uploading / downloading files to / from a remote host.
4 cu
Call Up a remote system and connect as a simple terminal.
5 uucp
UNIX to UNIX copy.
6 telnet
Utility and protocol for connecting a remote host.
7 rlogin
Remote login, initates a session on a remote host.
8 rsh
Remote shell, executes command(s) on a remote host.
9 rcp
Remote copy, copies files between two different networked machines.
10 ssh
Secure shell, logs onto a remote host and executes commands there.
III Local Network
1 write
This is a utility for terminal-to-terminal communication.
IV Mail
vacation
This utility automatically replies to e-mail that the intended recipient is on vacation and temporarily unavailable.
12.7. Terminal Control Commands
1 tput
Initialize terminal and/or fetch information about it from terminfo data.
2 reset
Reset terminal parameters and clear text screen.
3 clear
The clear command simply clears the text screen at the console or in an xterm.
4 script
This utility records (saves to a file) all the user keystrokes at the command line in a console or an xterm window.
12.8. Math Commands
1 factor
Decompose an integer into prime factors.
2 bc, dc
These are flexible, arbitrary precision calculation utilities.
bc has a syntax vagule resembling C.
dc uses RPN ("Reverse Polish Notation").
3 awk
Yet another way of doing floating point math in a script is using awk's built-in match funcitons in a shell wrapper.
12.9. Miscellaneous Commands
1 jot, seq
These utilities emit a sequence of integers, with a user selected increment.
2 run-parts
The run-parts command executes all the scripts in a target directory, sequentially in ASCII-sorted filename order.
3 yes
In its default behavior the yes command feeds a continuous string of the character y followed by a line feed to stdout.
4 banner
Prints arguments as a large vertical banner to stdout, using an ASCII character (default '#').
5 printenv
Show all the environmental variables set for a particular user.
6 lp
The lp and lpr commands send file(s) to the print queue, to be printed as hard copy.
7 tee
This is a redirection operator, but with a difference.
8 mkfifo
This obscure command creates a named pipe, a temporary first-in-first-out buffer for transferring data between processes.
9 pathchk
This command checks the validity of a filename.
10 dd
This is the somewhat obscure and much feared "data duplicator" command.
11 od
The od, or octal dump filter converts input (or files) to octal or other bases.
12 hexdump
Performs a hexadecimal, octal, decimal, or ASCII dump of a binary file.
13 m4
A hidden treasure, m4 is a powerful macro processor utility, virtually a complete language.
-----------------------------------------------------------------------------
Chapter 13. System and Administrative Commands
I Users and Groups
1 chown, chgrp
The chown command changes the ownership of a file or files.
The chgrp command changes the group ownership of a file or files.
2 useradd, userdel
The useradd administrative command adds a user account to the system and creates a home directory for that particular user, is so specified.
The corresponding userdel command removes a user account from the system and deletes associated files.
3 id
The id command lists the real and effective user IDs and the group IDs of the current user.
4 who
Show all users logged on to the system.
whoami is similar to who -m, but only lists the user name.
5 w
Show all logged on users and the processes belonging to them.
6 logname
Show current user's login name.
7 su
Runs a program or script as a substitute user.
8 users
Show all logged on users.
9 ac
Show users' logged in time, as read from /var/log/wtmp.
10 last
List last logged in users, as read from /var/log/wtmp
11 groups
Lists the current user and the groups she belongs to.
12 newgrp
Change user's group ID without logging out.
II Terminals
1 tty
Echoes the name of the current user's terminal.
2 stty
Show and/or changes terminal settings.
3 tset
Show or initialzie terminal settings.
4 setserial
Set or display serial port parameters.
5 getty, agetty
The initialization process for a terminal users getty or agetty to set it up for login by a user.
6 mesg
Enables or disables write access to the current user's terminal.
7 wall
This is an acronym for "write all", i.e., sending a message to all users at every terminal logged into the network.
8 dmesg
Lists all system bootup messages to stdout.
III Information and Statistics
1 uname
Output system specifications (OS, kernel version, etc.) to stdout.
2 arch
Show system architecture.
3 lastcomm
Gives information about previous commands, as stored in the /var/account/pacct file.
4 lastlog
List the last login time of all system users.
5 lsof
List open files.
6 strace
Diagnostic and debugging tool for tracing system calls and signals.
7 free
Shows memory and cache usage in tabular form.
8 procinfo
Extract and list information and statistics from the /pro pseudo-filesystem.
9 lsdev
List devices, that is, show installed hardware.
10 du
Show (disk) file usage, recursively.
11 df
Shows filesystem usage in tabular form.
12 stat
Gives detailed and verbose statistics on a given file (even a directory or device file) or set of files.
13 vmstat
Display virtual memory statistics.
14 netstat
Show current network statistics and information, such as routing tables and active connections.
15 uptime
Shows how long the system has been running, along with assocated statistics.
16 hstname
Lists the systme's host name.
17 hostid
Echo a 32-bit hexadecimal numerical identifier for the host machine.
18 sar
Invoking sar (system activity report) gives a very detailed rundown on system statistics.
IV System Logs
1 logger
Appends a user-generated message to the system log(/var/log/messages).
2 logrotate
This utility manages the system log files, rotating, compressing, deleting, and/or mailing them, as appropriate.
V Job Control
1 ps
Process Statistics: lists currently executing processes by owner and PID (process id).
2 pstree
Lists currently executing processes in "tree" format.
3 top
Continuously updated display of most cpu-intensive processes.
4 nice
Run a background job with an altered priority.
5 nohup
Keeps a command running even after user logs off.
6 pidof
Identifies process id (pid) of a running job.
7 fuser
Identifies the process (by pid) that are accessing a given file, set of files, or directory.
8 crond
Administrative program scheduler, performing such duties as cleaning up and deleting system log files and updating the slocate database.
VI Process Control and Booting
1 init
The init command is the parent of all processes.
2 telinit
Symlinked to init, this is a means of changing the system runlevel, usually done for system maintenance or emergency filesystem repairs.
3 runlevel
Show the current and last runlevel, that is, whether the system is halted (runlevel 0), in single-user mode (1), in multi-user mode (2 or 3), in X Windows (5), or rebooting (6).
4 halt, shutdown, reboot
Command set to shut the system down, usually just prior to a power down.
VII Network
1 ifconfig
Network interface configuration and tuning utility.
2 route
Show info about or make changes to the kernel routing table.
3 chkconfig
Check network configuration.
4 tcpdump
Network packet a "sniffer".
VIII Filesystem
1 mount
Mount a filesystem, usually on an external device, such as a floppy or CDROM.
2 umount
Unmount a currently mounted filesystem.
3 sync
Forces an immediate write of all updated data from buffers to hard drive.
4 losetup
Sets up and configures loopback devices.
5 mkswap
Creates a swap partition or file.
6 swapon, swapoff
Enable / disable swap partition or file.
7 mke2fs
Create a Linux ext2 filesystem.
8 tune2fs
Tune ext2 filesystem.
9 dumpe2fs
Dump (list to stdout) very verbose filesystem info.
10 hdparm
List or change hard disk parameters.
11 fdisk
Create or change a partition table on a storage device, usually a hard drive.
12 fsck, e2fsck, debugfs
Filesystem check, repair, and debug command set.
fsck: a front end for checking a UNIX filesystem (may invoke other utilities).
e2fsck: ext2 filesystem checker.
debugfs: ext2 filesystem debugger.
13 badblocks
Checks for bad blocks (physical media flaws) on a storage device.
14 mkbootdisk
Creates a boot floppy which can be used to bring up the system if, for example, the MBR (master boot record) becomes corrupted.
15 chroot
CHange ROOT directory.
16 lockfile
This utility is part of the procmail package.
17 mknod
Creates block or character device files (may be necessary when installing new hardware on the system).
19 tmpwatch
Automatically deletes files which have not been accessed within a specified period of time.
20 MAKEDEV
Utility for creating device files.
IX Backup
1 dump, restore
The dump command is an elaborate filesysstem backup utility, generally used on larger installations and networks.
2 fdformat
Perform a low-level format on a floppy disk.
X System Resources
1 ulimit
Sets an upper limit on system resources.
2 umask
User file creation MASK.
3 rdev
Get info about or make changes to root device, swap space, or video mode.
XI Modules
1 lsmod
List installed kernel modules.
2 insmod
Force insertion of a kernel module.
3 modprobe
Module loader that is normally invoked automatically in a startup script.
4 depmod
Creates module dependency file, usually invoked from startup script.
XII Miscellaneous
1 env
Runs a program or script with certain environmental variables set or changed (without changing the overall system environment).
2 ldd
Show shared lib dependencies for an executable file.
3 strip
Remove the debugging symbolic references from an executable binary.
4 nm
List symbols in an unstripped complied binary.
5 rdist
Remote distribution client: ssnchronizes, clones, or backs up a file system on a remote server.
Chapter 14. Command Substtution
1 backquotes (`...`)
2 $(COMMAND)
----------------------------------------------------------------------------
Chapter 15. Arithmetic Expansion
1 Variations
1 expr
2 let
3 $((...))
----------------------------------------------------------------------------
Chapter 16. I/O Redirection
I Redirect and Pipe
1 >
Redirect stdout to a file.
2 :> filename
The > truncates file "filename" to zero length.
3 >>
Redirect stdout to a file.
4 1>filename
Redirect stdout to file "filename".
5 1>>filename
Redirect and append stdout to file "filename".
6 2>filename
Redirect stderr to file "filename".
7 2>>filename
Redirect and append stderr to file "filename".
8 2>&1
Redirects stderr to stdout.
9 i>&j
Redirects file descriptor i to j.
10 >&j
Redirects, by default, file descriptor 1 (stdout) to j.
11 0<
<
Accept input from a file.
12 [j]<>filename
Open file "filename" for reading and writing, and assign file descriptor "j" to it.
If "filename" does exist, create it.
If file descriptor "j" is not specified, default to fd 0, stdin.
13 |
Pipe.
14 command < input-file > output-file
15 command1 | command2 | command3 > output-file
II Closing File Descriptors
1 n<&-
Close input file descriptor n.
2 0<&-, <&-
Close stdin
3 n>&-
Close output file descriptor n.
4 1>&-, >&-
Close stdout.
16.1 Using exec
1 exec <filename
The exec <filename command redirects stdin to a file.
16.2. Redirecting Code Blocks
1 Redirected while loop
while [ condition ]
do
COMMAND
......
done < "$Filename"
2 Alternate form of redirected while loop
exec 3<&0
exec 0<"$Filename"
while [ condition ]
do
COMMAND
.......
done < "$Filename"
exec 0<&3
exec 3<&-
3 Redirected until loop
until [ condition ]
do
COMMAND
.......
done < "$Filename"
4 Redirected for loop
for file in "list"
do
COMMAND
.......
done < "$Filename"
5 Redirected for loop (both stdin and stdout redirected)
for file in "list"
do
COMMAND
.......
done < "$Filename" > "$Savefile"
6 Redirected if/then test
if [ condition ]
then
COMMAND
......
done < "$Filename"
16.3. Applications
--------------------------------------------------------------------------
Chapter 17. Here Documents
interactive-program <<LimitString
command1
command2
....
LimitString
--------------------------------------------------------------------------
Chapter 19. Regular Expressions
19.1. A Brief Introduction to Regular Expressions
I The main uses for Regular Expressions
1 *
The asterisk * matches any number of repeats of the character string or RE preceding it, including zero.
2 .
The dot . matches one character, except a newline.
3 ^
The caret ^ matches the beginning of a line, but sometimes, depending on context, negates the meaning of a set of characters in an RE.
4 $
The dollar sign $ at the end of an RE matches the end of a line.
5 [...]
Brackets [...] enclose a set of characters to match in a single RE.
6 /
The backslash / escapes a special character, which means that character gets interpreted literally.
II Extended REs. (used in egrep, awk, and Perl)
1 ?
The question mark ? matches zero or one of the previous RE.
2 +
The plus + matches one or more of the previous RE.
3 /{/}
Escaped "curly brackets" /{/} indicate the number of occurrences of a preceding RE to match.
4 ()
Parenthess () enclose groups of REs.
5 |
The | "or" RE operator matches any of a set of alternate characters.
III POSIX Character Classes. [:class:]
1 [:alnum:]
matches alphabetic or numberic characters.
2 [:alpha:]
matches alphabetic characters.
3 [:blank:]
matches a space or a tab.
4 [:cntrl:]
matches control characters.
5 [:digit:]
matches (decimal) gigits.
6 [:graph:]
graphic printable characters. Matches characters in the range of ASCII 33-126.
7 [:lower:]
matches lowercase alphabetic characters.
8 [:print:]
printable characters. Matches characters in the range of ASCII 32-126. This is the same as [:graph:], above, but adding the space character.
9 [:space:]
matches whitespace characters (space and horizontal tab).
10 [:upper:]
matches uppercase alphabetic characters.
11 [:xdigit:]
matches hexadecimal digits. This is equivalent to [0-9A-Fa-f].
Note:
Important POSIX character classes generally require quoting or double brackets ([[]]).
19.2. Globbing
1 *
2 []
3 ^
4 {,}
--------------------------------------------------------------------------
Chapter 20. Subshells
I Command List in Parenthess
(command1; command2; command3;...)
II Dedicated Environment
COMMAND1
COMMAND2
COMMAND3
(
IFS=:
PATH=/bin
unset TERMINFO
set -C
shift 5
COMMAND4
COMMAND5
exit 3 # Only exits the subshell.
)
# The parent shell has not been affected, and the environment is preserved.
COMMAND6
COMMAND7
III Test whether a variable is defined.
if (set -u; : $variable) 2> /dev/null
then
echo "Variable is set."
fi
# Could also be written [[ ${variable-x} != x || ${variable-y} != y ]]
# or [[ ${variable-x} != x$variable ]]
# or [[ ${variable+x} = x ]])
IV Running parallel processes in subshells
--------------------------------------------------------------------------
Chapter 21. Restricted Shells
I Disabled commands in restricted shells
--------------------------------------------------------------------------
Chapter 22. Process Substitution
I Command substitution template
1 >(command)
2 <(command)
Note:
This uses /dev/fd/<n> files to send the results of the process within parentheses to another process.
--------------------------------------------------------------------------
Chapter 23. Functions
23.1. Complex Functions and Function Complexities
I the function form.
function function_name {
command...
}
or
function_name() {
command...
}
II Pass arguments and an exit status
1 Pass arguments
form: function_name $arg1 $arg2
2 Exit and Return
i) exit status
Functions return a value, called an exit status.
ii) return
Terminates a function and this exit status is assigned to the variable $?.
23.2. Local Variables
I local variables
A variable declared as local is one that is visible only within the block of code in which it appears.
II local variables make recursion possible.
--------------------------------------------------------------------------
Chapter 24. Aliases
I Aliase
A Bash alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence.
II unalias
The unalias command removs a previously set alias.
--------------------------------------------------------------------------
Chapter 25. List Constructs
I Chaining together commands
1 and list
command-1 && command-2 && command-3 && ... command-n
2 or list
command-1 || command-2 || command-3 || ... command-n
--------------------------------------------------------------------------
Chapter 26. Arrays
Newer version of bash support one-dimensional arrays.
I Declaration
Arrays may be declared with the variable[xx] or explicitly by a declare -a variable statement.
II dereference
To dereference (find the contents of) an array variable, use curly bracket notation, that is, ${variable[xx]}.
1 refers to all the elements of the array
${array_name[@]}
${array_name[*]}
2 get a count of the number of elements in an array
${#array_name[@]}
${#array_name[*]}
3 give the length of the first element of the array
${#array_name}
--------------------------------------------------------------------------
Chapter 27. Files
I Startup files
1 /etc/profile
systemwide defaults, mostly setting the environment.
2 /etc/bashrc
systemwide functions and aliases for Bash.
3 $HOME/.bash_profile
user-specific Bash environmental default settings.
4 $HOME/.bashrc
user-specific Bash environmental default settings.
--------------------------------------------------------------------------
Chapter 28. /dev and /peeroc
28.1 /dev
The /dev directory contains entries for the physical devices that may or may not be present in the hardware.
I df
You can use df to show the hard drive partitions containing the mounted
filesystem(s) having entries in /dev.
28.2. /proc
The /proc directory is actually a pseudo-filesystem.
I command
cat /proc/devices
cat /proc/interrupts
cat /proc/partitions
cat /proc/loadavg
--------------------------------------------------------------------------
Chapter 29. Of Zeros and Nulls
I Uses of /dev/null
Think of /dev/null as a "blcak hole".
ex:
rm $badname 2> /dev/null
cat /dev/null > /var/logmessages
# : > /var/log/messges
cat /dev/null > /var/log/wtmp
II Uses of /dev/zero
/dev/zero is a pseudo file and contains nulls (numerical zeros, not the ASCII kind).
------------------------------------------------------------------------
Chapter 30. Debugging
The Bash shell contains no debugger, nor even any debugging-specific commands or constructs.
I delete the file with space
badname = `ls | grep ' '`
rm "$badname"
rm */ *
rm *" "*
rm *' '*
II Summarizing the sympoms of a buggy scipt.
1 It bombs with an error message syntax error
2 It runs, but does not work as expected (logic error)
3 It runs, works as expected, but has nasty side effects (logic bomb).
III Tools for debugging non-working scripts include:
1 echo statements at critical points in the script to trace the varaibles, and otherwise give a snapshot of what is going on.
2 using the tee filter to check processes or data flows at critical points.
3 setting option flags -n -v -x
sh -n scriptname (set -n or set -o noexec)
sh -v scriptname (set -v or set -o verbose)
sh -nv scriptname
sh -x scriptname (set -x or set -o xtrace)
set -u or set -o nounset
4 Using an "assert" function to test a variable or condition at scritical points in a script. (This is an idea borrowed from C.)
5 trapping at exit.
IV Trapping signals
1 trap
Specifies an action on receipt of a signal; also userful for debugging.Note:
trap '' 2 # Signal 2 is Control-C, now disabled.
command
command
command
trap 2 # Reenables Control-C
--------------------------------------------------------------------------
Chapter 31. Options
I Options are setting that change shell and/or script behavior.
1 set -o verbose | set -v
Note:
To disable an option within a scipt, use set +o option-name or set +option-abbrev.
ex:
set -o verbose
set +o verbose
set -v
set +v
2 An alternate method of enabling options in a script is to specify them immediately following the #! script header.
#!/bin/bash -x
#
# Body of script follows.
3 bash -v script-name | bash -o verbose script-name
4 bash options
Table 31-1. bash options
Abbreviation Name Effect
-C noclobber Prevent overwriting of files by redirection (may be overridden by >|)
-D (none) List double-quoted strings prefixed by $, but do not execute commands in script
-a allexport Export all defined variables
-b notify Notify when jobs running in background terminate (not of much use in a script)
-c ... (none) Read commands from ...
-f noglob Filename expansion (globbing) disabled
-i interactive Script runs in interactive mode
-p privileged Script runs as "suid" (caution!)
-r restricted Script runs in restricted mode (see Chapter 21).
-u nounset Attempt to use undefined variable outputs error message, and forces an exit
-v verbose Print each command to stdout before executing it
-x xtrace Similar to -v, but expands commands
-e errexit Abort script at first error (when a command exits with non-zero status)
-n noexec Read commands in script, but do not execute them (syntax check)
-s stdin Read commands from stdin
-t (none) Exit after first command
- (none) End of options flag. All other arguments are positional parameters.
-- (none) Unset positional parameters. If arguments given (-- arg1 arg2), positional parameters set to arguments.
--------------------------------------------------------------------------
Chapter 32. Gotchas
1 Assigning reserved words or characters to variable names.
2 Using a hyphen or other reserved characters in a varialbe name.
3 Using the same name for a variable and a function.
4 Using whitespace inappropriately.
5 Assuming uninitialized variables are "zeroed out".
Note:
Sometimes variables within "test"brackets ([]) need to be quoted (double qutoes). Failure to do so may cause unexpected behavior.
6 Attempting to user - as a redirection operator will usually result in an unpleasant surprise.
7 Using Bash version 2+ functionality may cause a bailout with error messages.
###########################################################################
##!/bin/bash
#
#minimum_version=2
## Since Chet Ramey is constantly adding features to Bash,
## you may set $minimum_version to 2.XX, or whatever is appropriate.
#E_BAD_VERSION=80
#
#if [ "$BASH_VERSION" /< "$minimum_version" ]
#then
# echo "This script works only with Bash, version $minimum or greater."
# echo "Upgrade strongly recommended."
# exit $E_BAD_VERSION
#fi
#
#...
##########################################################################
8 Using Bash-specific functionality in a Bourne shell script(#!/bin/sh) on a non-Linux machine may cause unexpected behavior.
9 A script with DOS-type newlines(/r/n) will fail to execute, since #!/bin/bash/r/n is not recognized, not the same as the expected #!/bin/bash/n.
10 A shell script headed by #!/bin/sh may not run in full Bash-compatibility mode.
11 A Script may not export variables back to its parent process.
#########################################################################
#WHATEVER=/home/bozo
#export WHATEVER
#exit 0
#
#bash$ echo $WHATEVER
#
#bash$
#########################################################################
12 Setting and manipulating variables in a subshell, then attempting to usethose same variables outside the scope of the subshell will result an unpleasant surprize.
13 Using "suid" commands in scripts is risky, as it may compromise system security.
14 Using shell scripts for CGI programming may be problematic.
Appendix
Danger is near thee --
Beware, beware, beware, beware.
Many brave hearts are asleep in the deep.
So beware --
Beware.
A.J. Lamb and H.W. Petrie
--------------------------------------------------------------------------
Chapter 33. Scripting With Style
33.1. Unofficial Shell Scripting Stylesheet
1 comment your code
Add comment to the code.
Add decriptive headers to the scrpits and functions.
2 Avoid using "magic numbers"
3 Choose descriptive names for variables and functions.
4 Use exit codes in a systematic and meaningful way.
5 Break complex scripts into simpler modules.
6 Don't use a complex construct where a simpler one will do.
--------------------------------------------------------------------------
Chapter 34. Miscellany
34.1. Interactive and non-interactive shells and scripts
An interacive shell reads commands from user input on a tty.
Non-interactive scripts can run in background, but interactive ones hang, waiting for input that never comes.
I itest a script whether needs to run in an interactive environment.
##########################################################################
# if [ -z $PS1 ] # no prompt?
# then
# # non-interactive
# ...
# else
# # interactive
# ...
# fi
##########################################################################
II the script can test for the presence of option "i" in the $- flag.
##########################################################################
# case $- in
# *i*) # interactive shell
# ;;
# *) # non-interactive shell
# ;;
# # (Thanks to "UNIX F.A.Q.", 1993)
##########################################################################
34.2. Shell Wrappers
I wrapper
A "wrapper" is a shell script that embeds a system command or utility, that save a set of parameters passed to that command. This is expecially useful with sed and awk.
ex:
awk
sed
perl
34.3. Tests and Comparisons: Alternatives
1 string comparsions:
[[]] []
2 arithmetic comparisons
(())
3 test
4 /bin/test
34.4. Optimizations
34.5. Assorted Tips
1 To keep a record of which user scripts have run during a particula session or over a number of session.
###########################################################################
# # Append (>>) following to end of each script tracked.
#
# date>> $SAVE_FILE #Date and time.
# echo $0>> $SAVE_FILE #Script name.
# echo>> $SAVE_FILE #Blank line as separator.
#
# # Of course, SAVE_FILE defined and exported as environmental variable in ~/.bashrc
# # (something like ~/.scripts-run)
###########################################################################
2 The >> operator appends lines to a file.
3 A shell script may act as an embedded command inside another shell script.
4 Put together files containing your favorite and most userful definitions and fuctions.
5 Use special-purpose comment headers to increase clarity and legibility in scripts.
6 Using the $? exit status variable.
7 Using the double parentheses construct, it is possible to user C-like syntax for setting and incrementing variables and in for and while loops.
8 It would be nice to be able to invoke X-Windows widgets from a shell script.
34.6. Oddities
A script can recursively call itself.
Caution:
Too many levels of recursion can exhaust the script's stack space, causing segfalut.
34.7. Portability Issues
set -o posix at the head of a script causes Bash to conform to POSIX 1003.2 standard.
34.8. shell Scripting Under Windows
Cygwin package from Cygnus and the MKS uitities from Mortice Kern Asswociates add shell scriptin capabilities to Windows.
--------------------------------------------------------------------------
Chapter 35. Bash, version 2
1 string expansion
2 Indirect variable references - the new way
$a Direct reference
${!a} Indirect reference
ex:
a=letter_of_alphabet
letter_of_alphabet=z
echo "a = $a" # Direct reference.
echo "Now a = ${!a}" # Indirect reference.
# The ${!variable} notation is greatly superior to the old "eval var1=/$$var2"
3 Using arrays and other miscellaneous trickery to deal four random hands from a deck of cards
--------------------------------------------------------------------------
Chapter 36. Endnotes
36.1. Author's Note
36.2. About the Author
HOW-2 Meet Women: The Shy Man's Guide to Relationships.
Software-Building HOWTO.
36.3. Tools Used to Produce This Book
36.3.1 Hardware
36.3.2 Software and Printware
i. vim
ii Openjade
iii. Norman Walsh's DSSSL stylesheets.
iv. DocBook, The Definitive Guide, by Norman Walsh and Leonard Muellner(O'Reilly, ISBN 1-56592-580-7).
36.4. Credits
--------------------------------------------------------------------------
Bibliography
Dale Dougherty and Arnold Robbins, Sed and Awk, 2nd edition, O'Reilly and Associates, 1997, 1-156592-225-5.
To unfold the full power of shell scripting, you need at least a passing familiarity with sed and awk. This is the standard tutorial. It includes an excellent introduction to "regular expressions". Read this book.
* Aeleen Frisch, Essential System Administration, 2nd edition, O'Reilly and Associates, 1995, 1-56592-127-5.
This excellent sys admin manual has a decent introduction to shell scripting for sys administrators and does a nice job of explaining the startup and initialization scripts. The book is long overdue for a third edition (are you listening, Tim O'Reilly?).
* Stephen Kochan and Patrick Woods, Unix Shell Programming, Hayden, 1990, 067248448X.
The standard reference, though a bit dated by now.
* Neil Matthew and Richard Stones, Beginning Linux Programming, Wrox Press, 1996, 1874416680.
Good in-depth coverage of various programming languages available for Linux, including a fairly strong chapter on shell scripting.
* Herbert Mayer, Advanced C Programming on the IBM PC, Windcrest Books, 1989, 0830693637.
Excellent coverage of algorithms and general programming practices.
* David Medinets, Unix Shell Programming Tools, McGraw-Hill, 1999, 0070397333.
Good info on shell scripting, with examples, and a short intro to Tcl and Perl.
* Cameron Newham and Bill Rosenblatt, Learning the Bash Shell, 2nd edition, O'Reilly and Associates, 1998, 1-56592-347-2.
This is a valiant effort at a decent shell primer, but somewhat deficient in coverage on programming topics and lacking sufficient examples.
* Anatole Olczak, Bourne Shell Quick Reference Guide, ASP, Inc., 1991, 093573922X.
A very handy pocket reference, despite lacking coverage of Bash-specific features.
* Jerry Peek, Tim O'Reilly, and Mike Loukides, Unix Power Tools, 2nd edition, O'Reilly and Associates, Random House, 1997, 1-56592-260-3.
Contains a couple of sections of very informative in-depth articles on shell programming, but falls short of being a tutorial. It reproduces much of the regular expressions tutorial from the Dougherty and Robbins book, above.
* Arnold Robbins, Bash Reference Card, SSC, 1998, 1-58731-010-5.
Excellent Bash pocket reference (don't leave home without it). A bargain at $4.95, but also available for free download on-line in pdf format.
* Arnold Robbins, Effective Awk Programming, Free Software Foundation / O'Reilly and Associates, 2000, 1-882114-26-4.
The absolute best awk tutorial and reference. The free electronic version of this book is part of the awk documentation, and printed copies of the latest version are available from O'Reilly and Associates.
This book has served as an inspiration for the author of this document.
* Bill Rosenblatt, Learning the Korn Shell, O'Reilly and Associates, 1993, 1-56592-054-6.
This well-written book contains some excellent pointers on shell scripting.
* Paul Sheer, LINUX: Rute User's Tutorial and Exposition, 1st edition, , 2002, 0-13-033351-4.
Very detailed and readable introduction to Linux system administration.
The book is available in print, or on-line.
* Ellen Siever and and the Staff of O'Reilly and Associates, Linux in a Nutshell, 2nd edition, O'Reilly and Associates, 1999, 1-56592-585-8.
The all-around best Linux command reference, even has a Bash section.
* The UNIX CD Bookshelf, 2nd edition, O'Reilly and Associates, 2000, 1-56592-815-6.
An array of six UNIX books on CD ROM, including UNIX Power Tools, Sed and Awk, and Learning the Korn Shell. A complete set of all the UNIX references and tutorials you would ever need at about $70. Buy this one, even if it means going into debt and not paying the rent.
Unfortunately, out of print at present.
* The O'Reilly books on Perl. (Actually, any O'Reilly books.)
-------------------------------------------------------------------------