Title Page Contents Index |
Professional Unix Shell Programming
Contents
Title Page
Professional Unix Shell Programming
Introduction
Who is this book for?
Selecting the right shell
The Korn Shell Language.
Features
History
Discovering the Version
Getting the Korn Shell
Source Code and Examples from this book.
Command line options
Rules of engagement
Interrupting the shell
Login sequence
getty
login
Environment
Sytem login scripts
User login scripts
$HOME/.profile
$HOME/.kshrc
Exit
Prompting.
Execution.
Commands
Simple Commands
setuid
 Typing commands and In-line Editing Options
Emacs Editing Mode.
Vi Editing Mode.
Setting options in the shell
Exit status
Environment
stdin, stdout, stderr
pipes
The symbol & (background)
The co-process symbol |&
The symbol && (and)
The symbol || (or)
redirection
The symbol > ( redirect out )
The symbol >> ( redirect append )
The < symbol (redirect input )
The << symbol (Here Document)
tee command
Basic File Descriptors
More Input/Output Redirection.
Redirection symbol <
Redirectin symbol >
The >| symbol ( redirect clobber )
<& digit
>& digit
<&- >&-
<&p
>&p
#>
Redirection Order
command files
Basic Definitions
Letters
Digits
Underscore
Blank
Newline
Metacharacter
Identifier
Word
Command
Special Command
Special Characters
Quotes
Locale
Escape Sequences
Backslash
Comments
Parameter Substitution
Variables
${var}
Scope
Active Variables
Reference Variables
Using Variables.
Variable
Arrays
Compound assignments
Special shell variables
Null
Parameter Expansion
String manipulation.
Parameter Replacement
Parameter Field Separation
Creating temporary files
Environment
Variable scope
Positional parameters
Special Variables
CDPATH
COLUMNS
DISPLAY
EDITOR
ENV
FCEDIT
FIGNORE
FPATH
HISTCMD
HISTEDIT
HISTFILE
HISTSIZE
HOME
IFS
LINENO
LINES
MAIL
MAILCHECK
MAILPATH
OLDPWD
OPTARG
OPTIND
PATH
PPID
PS1, PS2,PS3,PS4
PWD
RANDOM
REPLY
SECONDS
SHELL
SYSV3
TERM
TMOUT
VISUAL
Regular Expressions and Pattern Matching
Collating elements:
RE Special Characters
The special characters are:
Behavior of special characters:
BRE Expression Anchoring
Classes of characters
Matching a range of characters
BREs Matching Multiple Characters
BRE Precedence
Matching a Specific Number Of Repetitions of a Pattern
Start of the Line and End of the Line
Matching one of two strings
Backreferences
Patterns in the Korn Shell
[[ string == pattern ]]
[[ string != pattern ]]
<operator>(<pattern-list>)
The Pattern Operators
Where patterns are used
expr (RE Operator)
Strings
Assigning.
Case.
Length.
Justification.
Splitting.
Joining.
Searching and substrings.
Replacing.
ksh88 and Posix replacements
Nameref
Shell Line Processes
~ Tilde Substitution.
Process Substitution.
Grouping Commands
Command Substitution
exec [arg]
exec <redirection>
. file (dot file or sourcing)
File Name Expansion.
The test commands; test, [, [[
Statements
if
case
while
until
for
break [n]
continue [n]
Printing
print
cat and the Here-Document
Functions
Autoload functions.
Shell math
(( expr ))
built-in math functions
Arithmetic Evaluation
bc
Base conversion
expr - evaluate arguments as an expression
let
[[ integer test operators
Keybinding
time pipeline
Signals
Built-in Commands (Special Commands).
. (dot)
: [arg]
[
alarm
bg job...
break n
builtin
builtin -ds -f file name ...
cd -LP arg
cd -LP old new
command
continue [n]
disown job...
echo arg ...
eval arg ...
exec
exit <n>
export
fc
fg job...
getconf [-a] name
getopts
hist
jobs
fg
bg
kill
let arg ...
newgrp arg ...
print
pwd
read
readonly
return n
set
shift [n]
sleep seconds
test
trap
type name ...
typeset
ulimit
umask -S mask
unalias
unset name
wait job ...
whence
Exit Continued
Important Utilities
grep utility
sed - stream editor
SED Addresses
SED Regular Expressions
SED Function Language
Write methods:
Tests:
Branching/Labels:
Delete:
Substitute/Replace:
Append:
Other:
cut - select portions of each line of a file
tr - translate characters
awk
Special clauses
Expressions
Flow Control Statements
String Functions
Arithmetic Functions
Built-In Variables
Other Common Commands
at
banner
basename, dirname
bc
cal
cat
cd
chmod
chown, chgrp
clear
cmp
col
compress
cp
cpio
dc
dd
df, bdf
diff
dircmp
du
ed
env
ex, edit
expand, unexpand
expr
file
find
fold
ftp
groups
hostname
id
iostat
ipcrm
ipcs
join
kill
line
login
logname
ls
man
mesg
mkdir
mkfifo
mktemp
more, page
mv
netstat
newgrp
nice
nl
nm
nodename
nohup
nroff
nslookup
od, xd
passwd
paste
pg
pr
printenv
ps
pwd
quota
rcp
rsh, remsh, rexec
resize
rlogin
rm
rmdir
sar
script
sleep
sort
spell
split
strings
stty
su
sum, cksum
tabs
tail
tar
tee
telnet
test
time, timex
touch
tput
true, false
tset, reset
uname
uniq
uptime
vi, view
vmstat
wc
which
who
whoami
write
xargs
xterm
Debugging
Shell syntax check
Active Variables
trap <list> DEBUG example debugger
Quotes
Typical Common mistakes
Arrays
Tests
Pipes
stdin in stdin
trap <list> EXIT
set -e or set –o errexit
set –v or set –o verbose
set –x or set –o xtrace
LINENO
typeset –ft function
Processing Arguments
getopts
getopt optstring arg ...
Shift through your arguments
Menus
Graphical shells
dtksh
tksh
wksh
history, fc - process command history list
hist
Other shells
getting other shells
rksh, restricted shell – restricted shell command interpreter
bash
Reissuing Commands
Finding File Names
zsh
csh and clones
rc
Posix shell
pdksh
Building your own Tools
Tip #1: Naming the script
Tip #2: Processing files line by line
Tip #3: Creating an infrastructure
Tip #4: Use a usage statement
Tip #5: Case tips
Use a typeset to allow acceptance of an upper or lower case answer to a question. Its easier than a case statement.
Tip #6: Give your users a default response
Tip #7: Connect to a socket from a shell script
Tip #8: Shifting variables in an array
Tip #9: A wrapper for read
Utility #1: Returning to where you have already been
Utility #2: Progress indicator
Utiltiy #3: Viewing man pages
Utility #4: Save
Utility #5: Which program is selected by the PATH?
Utility #6: Pstree and recursion in the shell.
Utility #7: Shell Archives
Utility #8: Logging Command
Utility #9: Changing a built-in command – replace cd
Utility #10: Ideas for using string manipulation on paths
Utility #11: Skipping comments and blank lines
Utility #12: Print a directory tree
Coding Standards
Extending the Korn Shell
The basics.
Locating important files and information:
Caviats
Afterword