
666
|
Chapter 6: The Bash Shell and Korn Shell
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
-n Suppress command numbering from the -l listing.
-r Reverse the order of the -l listing.
-s Equivalent to -e -. Not in ksh88.
fc
fc
ksh93 alias for hist.
fg
fg [jobIDs]
Bring current job or jobIDs to the foreground. See the earlier
section “Job Control.”
fi
fi
Reserved word that ends an if statement. (Don’t forget to use it!)
for
for x [in list]
do
commands
done
For variable x (in optional list of values) do commands.Ifin list is
omitted, "$@" (the positional parameters) is assumed.
Examples
Paginate files specified on the command line; save each result:
for file; do
pr $file > $file.tmp
done
Search chapters for a list of words (like fgrep -f):
for item in `cat program_list`
do
echo "Checking chapters for"
echo "references to program $item..."
grep -c "$item.[co]" chap*
done
Extract a one-word title from each file and use as new filename:
for file
do
name=`sed -n 's/NAME: //p' $file`
mv $file $name
done
for
for ((init; cond; incr))
do
commands
done
Bash and ksh93. Arithmetic for loop, similar to C’s. Evaluate init.
While cond is true, execute the body of the loop. Evaluate incr