This commit is contained in:
gferg 2002-06-17 13:17:07 +00:00
parent eebbb075be
commit 03e3c3b31f
15 changed files with 793 additions and 379 deletions

View File

@ -3,6 +3,84 @@ RELEASE HISTORY
Change log
Version 1.4
'MANGO' release
06/16/02
1) In "Special Characters" chapter:
Added "<" and ">" ASCII comparison entry.
Added "\<" and "\>" word boundary in a regular expression entry.
Added "&>" to redirection characters.
Added "history mechanism" comment to "!" entry.
2) In "Debugging" chapter:
Added "missing-keyword.sh" example of error message, with note.
Minor language clarification.
3) In "Tests" chapter:
Added material to "ex11.sh" example.
Changed "cmp a b >/dev/null" inline example to "cmp a b &>/dev/null
(thanks Baris Cicek).
4) In "I/O" Redirection chapter:
Added "&>filename" to redirection chart.
5) In "Of Zeros and Nulls" chapter:
Added comment to "suppressing output" inline example.
6) In "External Commands and Filters" chapter:
Moved "diff", "patch", "diff3", "sdiff", "cmp", and "comm" from "Text
Processing Commands" section to "File and Archiving Commands" section, and
created a "Comparison" subsection for them.
Moved "ptx" from "Text Processing Commands" section to "File and Archiving
Commands" section.
Gave the sections descriptive subtitles.
7) In "Text Processing Commands" of "External Commands and Filters" chapter:
Added tests to "file-comparison.sh" example.
At "head", added "script-detector.sh" example.
8) In "Miscellaneous Commands" section of "External Commands" Chapter:
Added "mcookie" entry.
9) In "Math Commands" section of "External Commands" chapter:
At "bc/dc" entry, added "hexconvert.sh" and "factr.sh" (thanks, Michel
Charpentier) examples of using "dc."
10) In "List Constructs" chapter:
Minor rewriting of "ex65.sh" example.
11) In "Contributed Scripts" appendix:
Added "blank-rename.sh" example.
12) In "Writing Scripts" section of "Exercises" appendix:
Added detail to "Safe Delete" exercise and moved it to "Medium"
subsection.
Added "Automatically Decompressing Files" exercise ("Easy" section).
Added "Lottery Numbers" exercise ("Easy" section).
Added "Passwords" exercise ("Intermediate" section).
Added "Fog Index" exercise ("Difficult" section).
13) In the "Security Section" of the "Miscellany" chapter:
Added 'Unix Scripting Malware' reference to the footnote.
14) In "Starting off with a Sha-Bang" chapter,
Fixed typo in comment in "ex2.sh" example ('wtemp' --> 'wtmp')
Thanks for pointing this out, Julien Reveret.
15) In "Internal Commands and Builtins" chapter:
At "read" entry, added in-line example of using "cat" to pipe to a
"read".
16) In "Optimizations" section of "Miscellany" chapter:
Added text.
17) Numerous typos corrected from a list sent in by Andreas Abraham (thanks!).
[Imagine that, I've been misspelling "Eratosthenes" since the 8th grade.]
Version 1.3
'TANGERINE' release
06/02/02
@ -30,7 +108,7 @@ Version 1.3
Added "Security Issues" section.
Added Rick Boivie's "pb.sh" script as a recursive script example.
6) In "Optimizations" section of "Miscellany" chapter
6) In "Optimizations" section of "Miscellany" chapter:
Editing of "loops" paragraph.
Added cross-reference to "monthlypmt.sh" script.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
#!/bin/bash
# badread.sh:
# Attempting to use 'read'
# Attempting to use 'echo and 'read'
#+ to assign variables non-interactively.
a=aaa

View File

@ -9,10 +9,30 @@ else
echo "First command-line argument is $1."
fi
echo
if [ -z "$1" ] # Functionally identical to above code block.
# if [ -z "$1" should work, but...
#+ Bash responds to a missing close bracket with an error message.
if /usr/bin/test -z "$1" # Same result as "test" builtin".
then
echo "No command-line arguments."
else
echo "First command-line argument is $1."
fi
echo
if [ -z "$1" ] # Functionally identical to above code blocks.
# if [ -z "$1" should work, but...
#+ Bash responds to a missing close-bracket with an error message.
then
echo "No command-line arguments."
else
echo "First command-line argument is $1."
fi
echo
if /usr/bin/[ -z "$1" # Again, functionally identical to above.
# if /usr/bin/[ -z "$1" ] # Works, but gives an error message.
then
echo "No command-line arguments."
else

View File

@ -11,7 +11,8 @@ a=`echo Hello!` # Assigns result of 'echo' command to 'a'
echo $a
# Note that using an exclamation mark (!) in command substitution
#+ will not work from the command line,
#+ since this triggers the Bash "history mechanism".
#+ since this triggers the Bash "history mechanism."
# Within a script, however, the history functions are disabled.
a=`ls -l` # Assigns result of 'ls -l' command to 'a'
echo $a # Unquoted, however, removes tabs and newlines.

View File

@ -36,7 +36,7 @@ fi
# * ) lines=$1;;
# esac
#
#* Skip ahead to "Loops" chapter to understand this.
#* Skip ahead to "Loops" chapter to decipher all this.
cd $LOG_DIR
@ -48,8 +48,8 @@ then
exit $E_XCD
fi # Doublecheck if in right directory, before messing with log file.
# far better is:
# ---
# far more efficient is:
#
# cd /var/log || {
# echo "Cannot change to necessary directory." >&2
# exit $E_XCD;
@ -65,7 +65,7 @@ mv mesg.temp messages # Becomes new log directory.
# cat /dev/null > messages
#* No longer needed, as the above method is safer.
cat /dev/null > wtmp # > wtemp has the same effect.
cat /dev/null > wtmp # ': > wtmp' and '> wtmp' have the same effect.
echo "Logs cleaned up."
exit 0

View File

@ -1,25 +1,25 @@
#!/bin/bash
# "Delete", not-so-cunning file deletion utility.
# Usage: delete filename
# delete.sh, not-so-cunning file deletion utility.
# Usage: delete filename
E_BADARGS=65
if [ -z "$1" ]
then
echo "Usage: `basename $0` filename"
exit $E_BADARGS
exit $E_BADARGS # No arg? Bail out.
else
file=$1 # Set filename.
fi
file=$1 # Set filename.
[ ! -f "$1" ] && echo "File \"$1\" not found. \
[ ! -f "$file" ] && echo "File \"$file\" not found. \
Cowardly refusing to delete a nonexistent file."
# AND LIST, to give error message if file not present.
# Note echo message continued on to a second line with an escape.
[ ! -f "$1" ] || (rm -f $1; echo "File \"$file\" deleted.")
[ ! -f "$file" ] || (rm -f $file; echo "File \"$file\" deleted.")
# OR LIST, to delete file if present.
# ( command1 ; command2 ) is, in effect, an AND LIST variant.

View File

@ -1,7 +1,7 @@
#!/bin/bash
# sieve.sh
# Sieve of Erastosthenes
# Sieve of Eratosthenes
# Ancient algorithm for finding prime numbers.
# This runs a couple of orders of magnitude

View File

@ -2,6 +2,7 @@
ARGS=2 # Two args to script expected.
E_BADARGS=65
E_UNREADABLE=66
if [ $# -ne "$ARGS" ]
then
@ -9,11 +10,16 @@ then
exit $E_BADARGS
fi
if [[ ! -r "$1" || ! -r "$2" ]]
then
echo "Both files to be compared must exist and be readable."
exit $E_UNREADABLE
fi
cmp $1 $2 > /dev/null # /dev/null buries the output of the "cmp" command.
# Also works with 'diff', i.e., diff $1 $2 > /dev/null
cmp $1 $2 &> /dev/null # /dev/null buries the output of the "cmp" command.
# Also works with 'diff', i.e., diff $1 $2 &> /dev/null
if [ $? -eq 0 ] # Test exit status of "cmp" command.
if [ $? -eq 0 ] # Test exit status of "cmp" command.
then
echo "File \"$1\" is identical to file \"$2\"."
else

View File

@ -2,8 +2,8 @@
# --------------------------------------------------------------
# The "gen0" file is a 10 x 10 grid using a period (.) for live cells,
#+ and an underscore (_) for dead ones. We cannot simply use spaces
#+ for dead cells in this file because of a peculiarity in Bash arrays
#+ (exercise for the reader: explain this).
#+ for dead cells in this file because of a peculiarity in Bash arrays.
# [Exercise for the reader: explain this.]
#
# Lines beginning with a '#' are comments, and the script ignores them.
__.__..___

View File

@ -2,7 +2,7 @@
# primes.sh: Generate prime numbers, without using arrays.
# Script contributed by Stephane Chazelas.
# This does *not* use the classic "Sieve of Erastosthenes" algorithm,
# This does *not* use the classic "Sieve of Eratosthenes" algorithm,
#+ but instead uses the more intuitive method of testing each candidate number
#+ for factors (divisors), using the "%" modulo operator.
@ -40,6 +40,6 @@ exit 0
# Uncomment lines 17 and 25 to help figure out what is going on.
# Compare the speed of this algorithm for generating primes
# with the Sieve of Erastosthenes (ex68.sh).
# with the Sieve of Eratosthenes (ex68.sh).
# Exercise: Rewrite this script without recursion, for faster execution.

View File

@ -41,7 +41,11 @@ fi
exit 0
# Exercise:
# --------
# Exercises:
# ---------
# What type of files will this not work on?
# How can this be fixed?
#
# Rewrite this script to process all the files in a directory
#+ containing spaces in their names, and to rename them,
#+ substituting an underscore for each space.

View File

@ -780,7 +780,7 @@ information and implementation details. </Para>
Apache-Compile-HOWTO</ULink>,
<CiteTitle>Apache Compile HOWTO (Linux edition)</CiteTitle>
</Para><Para>
<CiteTitle>Updated: April 2002</CiteTitle>.
<CiteTitle>Updated: June 2002</CiteTitle>.
Describes how to compile the Apache Webserver with
important modules like mod_perl, mod_dav, mod_auth_ldap,
mod_dynvhost, mod_roaming, mod_jserv, and mod_php. </Para>

View File

@ -134,7 +134,7 @@ around the 5070 SBUS host based RAID controller by Antares Microsystems.
Apache-Compile-HOWTO</ULink>,
<CiteTitle>Apache Compile HOWTO (Linux edition)</CiteTitle>
</Para><Para>
<CiteTitle>Updated: April 2002</CiteTitle>.
<CiteTitle>Updated: June 2002</CiteTitle>.
Describes how to compile the Apache Webserver with
important modules like mod_perl, mod_dav, mod_auth_ldap,
mod_dynvhost, mod_roaming, mod_jserv, and mod_php. </Para>

View File

@ -717,7 +717,7 @@ applications, etc. that work on the Linux platform. </Para>
Apache-Compile-HOWTO</ULink>,
<CiteTitle>Apache Compile HOWTO (Linux edition)</CiteTitle>
</Para><Para>
<CiteTitle>Updated: April 2002</CiteTitle>.
<CiteTitle>Updated: June 2002</CiteTitle>.
Describes how to compile the Apache Webserver with
important modules like mod_perl, mod_dav, mod_auth_ldap,
mod_dynvhost, mod_roaming, mod_jserv, and mod_php. </Para>