mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
757d140981
commit
aba5405745
|
@ -6,6 +6,124 @@
|
|||
http://personal.riverusers.com/~thegrendel/Change.log
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Intermediate release.
|
||||
Working toward version 4.0, Winterberry release.
|
||||
|
||||
1) "System and Administrative Commands" chapter:
|
||||
Added "gnome-mount" entry.
|
||||
Modified "command" entry to eliminate ambiguity.
|
||||
At "uname" entry, reordered usage example.
|
||||
At "watch" entry, noted that piping output of "watch command" to
|
||||
"grep" doesn't work.
|
||||
In "Filesystem" subsection,
|
||||
At "lockfile" entry, additional comment in in-line example script.
|
||||
In "Job Control" subsection,
|
||||
Added "killall" entry.
|
||||
At "nice" entry, elaborated on "renice," "snice," and "skill."
|
||||
|
||||
2) In "Communications Commands" section of "External Commands" chapter:
|
||||
At "ping" entry, added in-line example script.
|
||||
|
||||
3) In "Text Processing" section of "External Commands" Chapter:
|
||||
At "tsort" entry, added material.
|
||||
|
||||
4) In "Arrays" chapter:
|
||||
Noted an exception to 'array2=( "${array1[@]}" )' array copying method.
|
||||
(Thank you, Jochen, DeSmet.)
|
||||
Extended "empty-array.sh"
|
||||
(Thank you, Omair Eshkenazi.)
|
||||
|
||||
5) In "Tests" chapter:
|
||||
In "Test Constructs" section:
|
||||
Fixed comment typos in "broken-links.sh" example.
|
||||
(Thank you, Omair Eshkenazi.)
|
||||
Added material to note about "test" builtin and /usr/bin/test
|
||||
not being equivalent.
|
||||
In "Other Comparison Operators" section:
|
||||
Rewrote the (short) intro.
|
||||
In "Test Your Knowledge of Tests" section:
|
||||
Updated intro to example snippet.
|
||||
|
||||
6) In "$RANDOM" section of "Variables Revisited" chapter:
|
||||
Fixed typo in comment in Jipe's in-line example.
|
||||
Added comment to "random-between.sh" example.
|
||||
(Thank you, Omair Eshkenazi, for both of the above.)
|
||||
|
||||
7) In the "Security Issues Section" of the "Miscellany" chapter:
|
||||
Fixed typo in second paragraph.
|
||||
(Thank you, Omair Eshkenazi.)
|
||||
|
||||
8) In "List Constructs" chapter:
|
||||
Modified "and list" setting variable to default value in-line example.
|
||||
(Thank you, Omair Eshkenazi.)
|
||||
|
||||
9) In "Job Control Commands" section of
|
||||
"Internal Commands and Builtins" chapter:
|
||||
At "kill" entry, added comment about additional file giving signal
|
||||
listing.
|
||||
|
||||
10) In "Time/Date Commands" section of "External Commands" chapter:
|
||||
At "touch" entry, added tip about not overwriting files.
|
||||
|
||||
11) In "Internal Commands and Builtins" chapter:
|
||||
Added short usage examples to "true" and "false" entries.
|
||||
|
||||
12) In "Bash, version 3" section of "Bash, versions 2 and 3" chapter:
|
||||
Added "pipefail" option.
|
||||
Also added this to table in "Options" chapter.
|
||||
At {x..y} "braces expansion operator entry,
|
||||
added a simple "echo" using this.
|
||||
(Thank you, Damon Puncer, for the suggestion.)
|
||||
|
||||
13) In "File and Archiving Commands" section of "External Commands" Chapter:
|
||||
At "diff" entry, added note about "diffstat."
|
||||
Moved "sum/cksum/md5sum/sha1sum" and "shred" entries
|
||||
to "Encoding and Encryption" subsection.
|
||||
|
||||
14) In "Contributed Scripts" appendix:
|
||||
Added "ha.sh" hashing script.
|
||||
(Thank you, Oliver Beckstein.)
|
||||
Added comments to "fifo.sh" script.
|
||||
(Thank you, Omair Eshkenazi.)
|
||||
More explicit reference to Mark Moraes copyright before
|
||||
his two scripts.
|
||||
|
||||
15) Moved "Here Documents" chapter from "Beyond the Basics" section to
|
||||
"Advanced Topics" section.
|
||||
|
||||
16) Moved "I/O Redirection" chapter from "Beyond the Basics" section to
|
||||
"Advanced Topics" section.
|
||||
|
||||
17) In "/dev" section of "/dev and /proc" chapter:
|
||||
Added material to "socket" footnote.
|
||||
|
||||
18) Split off the three "Command" chapters into a different Part.
|
||||
Put an alphabetical command cross-reference into the Introduction
|
||||
to that Part.
|
||||
>> This is a major reorganization of the document. <<
|
||||
|
||||
19) In "Special Characters" chapter:
|
||||
Added "extended brace expansion" (Bash 3+) entry.
|
||||
Added "{} -- placeholder for text after "xargs -i" . . .
|
||||
|
||||
20) In "Reference Cards" appendix:
|
||||
In "Miscellaneous Constructs" table:
|
||||
Added "extended brace expansion" (Bash 3+) entry.
|
||||
Added "{}" (text replacement) entry.
|
||||
Added more hypertext links.
|
||||
Cleanups.
|
||||
|
||||
21) Delineated all references to "root user" with <firstterm> tags.
|
||||
|
||||
22) Changed many of the <emphasis> tags in the document
|
||||
to more appropriate <firstterm>, <filename>, and <varname>, etc.
|
||||
|
||||
23) Changed certain of the <varname> tags to the more appropriate <parameter>.
|
||||
|
||||
24) Various minor fixups on example scripts.
|
||||
|
||||
|
||||
|
||||
Version 3.9
|
||||
Spiceberry release, 05/15/06
|
||||
|
||||
|
@ -114,7 +232,7 @@ Blaeberry release, 02/26/06
|
|||
Fixed minor typo at "${parameter:+alt_value}" example.
|
||||
(Thank you, Jemshad O K)
|
||||
|
||||
8) Partitioned "Security Section" of the "Miscellany" chapter
|
||||
8) Partitioned "Security Issues Section" of the "Miscellany" chapter
|
||||
into two subsections.
|
||||
Added subsection about "shc" utility for compiling script source.
|
||||
|
||||
|
@ -2289,7 +2407,7 @@ Version 1.4 (minor update)
|
|||
Added "Passwords" exercise ("Intermediate" section).
|
||||
Added "Fog Index" exercise ("Difficult" section).
|
||||
|
||||
13) In the "Security Section" of the "Miscellany" chapter:
|
||||
13) In the "Security Issues Section" of the "Miscellany" chapter:
|
||||
Added 'Unix Scripting Malware' reference to the footnote.
|
||||
|
||||
14) In "Starting off with a Sha-Bang" chapter,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
The following is the mandatory copyright notice for the two included
|
||||
"contrib" scripts by Mark Moraes, "behead.sh" and "ftpget.sh".
|
||||
"contrib" scripts by Mark Moraes, "behead.sh" and "ftpget.sh". It is part
|
||||
of the combined HTML/source tarball of the _ABS Guide_, and included by
|
||||
reference in the PDF version.
|
||||
|
||||
|
||||
/*
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@ do
|
|||
echo "$filename" | grep -q " " # Check whether filename
|
||||
if [ $? -eq $FOUND ] #+ contains space(s).
|
||||
then
|
||||
fname=$filename # Strip off path.
|
||||
fname=$filename # Yes, this filename needs work.
|
||||
n=`echo $fname | sed -e "s/ /_/g"` # Substitute underscore for blank.
|
||||
mv "$fname" "$n" # Do the actual renaming.
|
||||
let "number += 1"
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
##############################################################
|
||||
|
||||
|
||||
#If no args are passed to the script set directorys to search
|
||||
#to current directory. Otherwise set the directorys to search
|
||||
#to the agrs passed.
|
||||
#If no args are passed to the script set directories-to-search
|
||||
#to current directory. Otherwise set the directories-to-search
|
||||
#to the args passed.
|
||||
####################
|
||||
[ $# -eq 0 ] && directorys=`pwd` || directorys=$@
|
||||
|
||||
#Setup the function linkchk to check the directory it is passed
|
||||
#for files that are links and don't exist, then print them quoted.
|
||||
#If one of the elements in the directory is a subdirectory then
|
||||
#send that send that subdirectory to the linkcheck function.
|
||||
#send that subdirectory to the linkcheck function.
|
||||
##########
|
||||
linkchk () {
|
||||
for element in $1/*; do
|
||||
|
|
|
@ -88,7 +88,7 @@ day_index () # Gauss' Formula:
|
|||
}
|
||||
|
||||
|
||||
calculate_difference () # Difference between to day indices.
|
||||
calculate_difference () # Difference between two day indices.
|
||||
{
|
||||
let "diff = $1 - $2" # Global variable.
|
||||
}
|
||||
|
|
|
@ -2,14 +2,15 @@
|
|||
# empty-array.sh
|
||||
|
||||
# Thanks to Stephane Chazelas for the original example,
|
||||
#+ and to Michael Zick for extending it.
|
||||
#+ and to Michael Zick and Omair Eshkenazi for extending it.
|
||||
|
||||
|
||||
# An empty array is not the same as an array with empty elements.
|
||||
|
||||
array0=( first second third )
|
||||
array1=( '' ) # "array1" consists of one empty element.
|
||||
array2=( ) # No elements . . . "array2" is empty.
|
||||
array0=( first second third )
|
||||
array1=( '' ) # "array1" consists of one empty element.
|
||||
array2=( ) # No elements . . . "array2" is empty.
|
||||
array3=( ) # What about this array?
|
||||
|
||||
echo
|
||||
ListArray()
|
||||
|
@ -18,14 +19,17 @@ echo
|
|||
echo "Elements in array0: ${array0[@]}"
|
||||
echo "Elements in array1: ${array1[@]}"
|
||||
echo "Elements in array2: ${array2[@]}"
|
||||
echo "Elements in array3: ${array3[@]}"
|
||||
echo
|
||||
echo "Length of first element in array0 = ${#array0}"
|
||||
echo "Length of first element in array1 = ${#array1}"
|
||||
echo "Length of first element in array2 = ${#array2}"
|
||||
echo "Length of first element in array3 = ${#array3}"
|
||||
echo
|
||||
echo "Number of elements in array0 = ${#array0[*]}" # 3
|
||||
echo "Number of elements in array1 = ${#array1[*]}" # 1 (Surprise!)
|
||||
echo "Number of elements in array2 = ${#array2[*]}" # 0
|
||||
echo "Number of elements in array3 = ${#array3[*]}" # 0
|
||||
}
|
||||
|
||||
# ===================================================================
|
||||
|
@ -38,6 +42,7 @@ ListArray
|
|||
array0=( "${array0[@]}" "new1" )
|
||||
array1=( "${array1[@]}" "new1" )
|
||||
array2=( "${array2[@]}" "new1" )
|
||||
array3=( "${array3[@]}" "new1" )
|
||||
|
||||
ListArray
|
||||
|
||||
|
@ -45,6 +50,7 @@ ListArray
|
|||
array0[${#array0[*]}]="new2"
|
||||
array1[${#array1[*]}]="new2"
|
||||
array2[${#array2[*]}]="new2"
|
||||
array3[${#array3[*]}]="new2"
|
||||
|
||||
ListArray
|
||||
|
||||
|
@ -56,7 +62,7 @@ echo
|
|||
echo "Stack height for array2 = $height"
|
||||
|
||||
# The 'pop' is:
|
||||
unset array2[${#array2[@]}-1] # Arrays are zero-based,
|
||||
unset array2[${#array2[@]}-1] # Arrays are zero-based,
|
||||
height=${#array2[@]} #+ which means first element has index 0.
|
||||
echo
|
||||
echo "POP"
|
||||
|
@ -66,7 +72,7 @@ ListArray
|
|||
|
||||
# List only 2nd and 3rd elements of array0.
|
||||
from=1 # Zero-based numbering.
|
||||
to=2 #
|
||||
to=2
|
||||
array3=( ${array0[@]:1:2} )
|
||||
echo
|
||||
echo "Elements in array3: ${array3[@]}"
|
||||
|
|
|
@ -12,6 +12,7 @@ echo -n "What is your name? "
|
|||
read name # Use # to erase last character typed.
|
||||
echo "Your name is $name."
|
||||
|
||||
# Warning: Even after the script exits, the new key value remains set.
|
||||
|
||||
exit 0
|
||||
|
||||
# Even after the script exits, the new key value remains set.
|
||||
# Exercise: How would you reset the erase character to the default value?
|
||||
|
|
|
@ -11,7 +11,8 @@ fi
|
|||
|
||||
echo
|
||||
|
||||
if /usr/bin/test -z "$1" # Same result as "test" builtin".
|
||||
if /usr/bin/test -z "$1" # Equivalent to "test" builtin.
|
||||
# ^^^^^^^^^^^^^ # Specifying full pathname.
|
||||
then
|
||||
echo "No command-line arguments."
|
||||
else
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Faxing (must have 'fax' installed).
|
||||
# Faxing (must have 'efax' package installed).
|
||||
|
||||
EXPECTED_ARGS=2
|
||||
E_BADARGS=65
|
||||
|
@ -14,24 +14,26 @@ fi
|
|||
|
||||
if [ ! -f "$2" ]
|
||||
then
|
||||
echo "File $2 is not a text file"
|
||||
echo "File $2 is not a text file."
|
||||
# File is not a regular file, or does not exist.
|
||||
exit $E_BADARGS
|
||||
fi
|
||||
|
||||
|
||||
fax make $2 # Create fax formatted files from text files.
|
||||
fax make $2 # Create fax formatted files from text files.
|
||||
|
||||
for file in $(ls $2.0*) # Concatenate the converted files.
|
||||
# Uses wild card in variable list.
|
||||
for file in $(ls $2.0*) # Concatenate the converted files.
|
||||
# Uses wild card (filename "globbing")
|
||||
#+ in variable list.
|
||||
do
|
||||
fil="$fil $file"
|
||||
done
|
||||
|
||||
efax -d /dev/ttyS3 -o1 -t "T$1" $fil # Do the work.
|
||||
efax -d /dev/ttyS3 -o1 -t "T$1" $fil # Finally, do the work.
|
||||
|
||||
|
||||
# As S.C. points out, the for-loop can be eliminated with
|
||||
# efax -d /dev/ttyS3 -o1 -t "T$1" $2.0*
|
||||
# but it's not quite as instructive [grin].
|
||||
# As S.C. points out, the for-loop can be eliminated with
|
||||
# efax -d /dev/ttyS3 -o1 -t "T$1" $2.0*
|
||||
#+ but it's not quite as instructive [grin].
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -12,7 +12,7 @@ LINES=5
|
|||
( date; uname -a ) >>logfile
|
||||
# Time and machine name
|
||||
echo --------------------------------------------------------------------- >>logfile
|
||||
tail -$LINES /var/log/messages | xargs | fmt -s >>logfile
|
||||
tail -$LINES /var/log/messages | xargs | fmt -s >>logfile
|
||||
echo >>logfile
|
||||
echo >>logfile
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ EXCLUDE=(
|
|||
|
||||
init () {
|
||||
# Let pipe command return possible rsync error, e.g., stalled network.
|
||||
set -o pipefail
|
||||
set -o pipefail # Newly introduced in Bash, version 3.
|
||||
|
||||
TMP=${TMPDIR:-/tmp}/${0##*/}.$$ # Store refined download list.
|
||||
trap "{
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
|
||||
# ==> 'su xyz' runs commands as user "xyz".
|
||||
# ==> 'ssh' invokes secure shell (remote login client).
|
||||
su xyz -c "ssh $THERE \"cat >/home/xyz/backup/${HERE}-daily.tar.gz\" < /pipe"&
|
||||
su xyz -c "ssh $THERE \"cat > /home/xyz/backup/${HERE}-daily.tar.gz\" < /pipe"&
|
||||
cd /
|
||||
tar -czf - bin boot dev etc home info lib man root sbin share usr var >/pipe
|
||||
tar -czf - bin boot dev etc home info lib man root sbin share usr var > /pipe
|
||||
# ==> Uses named pipe, /pipe, to communicate between processes:
|
||||
# ==> 'tar/gzip' writes to /pipe and 'ssh' reads from /pipe.
|
||||
|
||||
|
@ -27,5 +27,8 @@
|
|||
# ==>+ as opposed to an "anonymous pipe", with |?
|
||||
# ==> Will an anonymous pipe even work here?
|
||||
|
||||
# ==> Is it necessary to delete the pipe before exiting the script?
|
||||
# ==> How could that be done?
|
||||
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -56,7 +56,8 @@ if [ $? != 0 ]; then
|
|||
exit $E_BADARGS
|
||||
fi
|
||||
shift
|
||||
trap 'rm -f ${TMPFILE} ; exit' 0 1 2 3 15
|
||||
trap 'rm -f ${TMPFILE} ; exit' 0 1 2 3 15
|
||||
# ==> Signals: HUP INT (Ctl-C) QUIT TERM
|
||||
# ==> Delete tempfile in case of abnormal exit from script.
|
||||
echo "user anonymous ${USER-gnu}@${SITE} > ${TMPFILE}"
|
||||
# ==> Added quotes (recommended in complex echoes).
|
||||
|
|
|
@ -33,3 +33,6 @@ ps ax | grep "$PROCESS_NAME" | awk '{print $1}' | xargs -i kill {} 2&>/dev/null
|
|||
# -----------------------------------------------------------
|
||||
|
||||
exit $?
|
||||
|
||||
# The "killall" command has the same effect as this script,
|
||||
#+ but using it is not quite as educational.
|
||||
|
|
|
@ -27,7 +27,9 @@ kill $t # May need 'kill -9' for stubborn process.
|
|||
|
||||
|
||||
# This entire script could be replaced by
|
||||
# kill $(pidof -x process_name)
|
||||
# kill $(pidof -x process_name)
|
||||
# or
|
||||
# killall process_name
|
||||
# but it would not be as instructive.
|
||||
|
||||
exit 0
|
||||
|
|
|
@ -93,6 +93,8 @@ randomBetween() {
|
|||
# ---------------------------------------------------------------------
|
||||
|
||||
spread=$((max-min))
|
||||
# Omair Eshkenazi points out that this test is unnecessary,
|
||||
#+ since max and min have already been switched around.
|
||||
[ ${spread} -lt 0 ] && spread=$((0-spread))
|
||||
let spread+=divisibleBy
|
||||
randomBetweenAnswer=$(((RANDOM%spread)/divisibleBy*divisibleBy+min))
|
||||
|
|
|
@ -24,3 +24,7 @@ echo "\"var\" = "$var""
|
|||
echo
|
||||
|
||||
exit 0
|
||||
|
||||
# This example is similar to the "reply.sh" script.
|
||||
# However, this one shows that $REPLY is available
|
||||
#+ even after a 'read' to a variable in the conventional way.
|
||||
|
|
|
@ -179,6 +179,7 @@ read Wopts
|
|||
# Read in the options to be passed to wget.
|
||||
|
||||
Woptions=" $Wopts"
|
||||
# ^ Why the leading space?
|
||||
# Assign to another variable.
|
||||
# Just for fun, or something . . .
|
||||
|
||||
|
|
Loading…
Reference in New Issue