From f3977fc7cee181f264f3a94ec68d403c595832f8 Mon Sep 17 00:00:00 2001 From: gferg <> Date: Mon, 25 Aug 2003 14:48:48 +0000 Subject: [PATCH] updated --- LDP/guide/docbook/abs-guide/Change.log | 88 ++- LDP/guide/docbook/abs-guide/abs-guide.sgml | 850 +++++++++++++++++++-- LDP/guide/docbook/abs-guide/encryptedpw.sh | 2 +- LDP/guide/docbook/abs-guide/erase.sh | 9 +- LDP/guide/docbook/abs-guide/ex72.sh | 4 +- LDP/guide/docbook/abs-guide/ex76.sh | 4 +- LDP/guide/docbook/abs-guide/manview.sh | 6 +- LDP/guide/docbook/abs-guide/pb.sh | 2 +- LDP/guide/docbook/abs-guide/poem.sh | 3 +- LDP/guide/docbook/abs-guide/symlinks.sh | 13 + 10 files changed, 883 insertions(+), 98 deletions(-) diff --git a/LDP/guide/docbook/abs-guide/Change.log b/LDP/guide/docbook/abs-guide/Change.log index 4f967d6c..a54adf8f 100644 --- a/LDP/guide/docbook/abs-guide/Change.log +++ b/LDP/guide/docbook/abs-guide/Change.log @@ -1,6 +1,86 @@ -RELEASE HISTORY -------- ------- -Change log + CHANGE LOG + & + Release History + + This file is available on-line at + http://personal.riverusers.com/~thegrendel/Change.log +------------------------------------------------------------------------ + +Version 2.0 +'GOOSEBERRY' release, 08/24/03 + +Comments: +In view of the cumulative changes in the last several updates, it's +bumped up to a major version. This is now officially a "mature" project. + + + +1) In "Manipulating Strings" section of "Variables Revisited" chapter: + Added negative index substring extraction example (Thanks, Dan + Jacobson). + +2) In "Sed appendix": + Changed title of second table, to make it less ambiguous. + +3) Changed "Sunsite" address in two examples. + +4) Made capitalization of example scripts more consistent. + +5) In "Command Substitution" chapter: + Fixed typo in backquotes discussion (Thanks, Jiri Beran). + +6) In "Process Substitution" chapter: + Added clarifying comment to SuSE script fragment (Thanks Ulrich Gayer). + +7) In "Invoking the script" section of + "Starting Off With a Sha-Bang" chapter: + Corrected typo in discussion + (" . . . not recommended is using sh "foo"). + (Thanks, Norman Megill.) + Noted that 'echo "\" invokes secondary prompt. + +9) In "Here Document" chapter: + Shuffled the order of a couple of examples. + Added warning about closing 'limit string' starting in first character + position on its line, with in-line example. (Also added a mention in + "Gotchas" chapter. + Added "script-generate.sh" example of generating program code + by disabling parameter substitution within the body of a 'here document.' + (Thanks, Albert Reiner, for the idea.) + +10) In "Miscellaneous" subsection of "System and Administrative Commands" + chapter: + Added listing for "dialog" toolsets. + +11) In "Assorted Tips" section of "Miscellany" chapter: + Added discussion of "dialog" toolsets, with "dialog.sh" example. + +12) In "Copyright" chapter: + Updated notices. + +13) Added "Reference Cards" appendix. + Thank you, Aurelio Marinho Jargas, for giving me the inspiration. + +14) In "Bibliography" section: + Added LINUX JOURNAL article, "Scripting for X Productivity" listing. + Added Jargas' entry for "Regular Expression wizard." + +15) In "Loop Control" section of "Loops and Branches" chapter: + Embellished "symlinks.sh" example with Jean Helou's alternative + method. + +16) Typo fixes supplied by Edward Scholtz (thanks!): + "Special Variable Types" section of "Introduction to Variables" chapter + "fairly simply way" --> "fairly simple way" + "Quoting" chapter + "advisable in enclose it" --> "advisable to enclose it" + +17) Corrected several minor typos in the text and script examples. + Version 1.9 [Cleanups & revisions] @@ -74,7 +154,7 @@ Version 1.8 [Cleanups & revisions] 4) In "blot-out.sh" script, updated the Peter Gutmann URL. 5) In "Miscellaneous" subsection of "System and Administrative Commands" - chapter" + chapter: Added "watch" command. 6) In the introduction, in reason not to use shell scripts, diff --git a/LDP/guide/docbook/abs-guide/abs-guide.sgml b/LDP/guide/docbook/abs-guide/abs-guide.sgml index be7425c7..f512924c 100644 --- a/LDP/guide/docbook/abs-guide/abs-guide.sgml +++ b/LDP/guide/docbook/abs-guide/abs-guide.sgml @@ -271,6 +271,8 @@ Uncomment line below to generate index. + + @@ -292,8 +294,8 @@ Uncomment line below to generate index. - 1.9 - 21 June 2003 + 2.0 + 24 August 2003 @@ -413,6 +415,13 @@ Uncomment line below to generate index. 'PERSIMMON' release: bugfixes and more material. + + 2.0 + 24 August 2003 + mc + 'GOOSEBERRY' release: Major update. + + @@ -421,19 +430,22 @@ Uncomment line below to generate index. This tutorial assumes no previous knowledge of scripting or programming, but progresses rapidly toward an intermediate/advanced level of instruction . . . all - the while sneaking in little snippets of UNIX wisdom and - lore. It serves as a textbook, a manual for - self-study, and a reference and source of knowledge on shell - scripting techniques. The exercises and heavily-commented - examples invite active reader participation, under the premise - that the only way to really learn scripting is to - write scripts. + the while sneaking in little snippets of UNIX wisdom and lore. It + serves as a textbook, a manual for self-study, and a reference and + source of knowledge on shell scripting techniques. The exercises + and heavily-commented examples invite active reader participation, + under the premise that the only way to really learn + scripting is to write scripts. + + This book is suitable for classroom use as a general + introduction to programming concepts. The latest update of this document, as an archived, bzip2-ed tarball including both the SGML source and rendered HTML, may be downloaded from + url="http://personal.riverusers.com/~thegrendel/abs-guide-2.0.tar.bz2"> the author's home site. See the change log for a revision history. @@ -662,7 +674,7 @@ Uncomment line below to generate index. Some flavors of UNIX (those based on 4.2BSD) take a four-byte magic number, requiring - a blank after the !, + a blank after the ! -- #! /bin/sh. @@ -790,7 +802,7 @@ fi script may therefore fail to execute. or alternatively bash scriptname. (Not - recommended is using sh <scriptname>, + recommended is using sh <scriptname, since this effectively disables reading from stdin within the script.) Much more convenient is to make the script itself directly executable with @@ -3040,7 +3052,7 @@ arch=$(uname -m) The bracket notation for positional - parameters leads to a fairly simply way of referencing + parameters leads to a fairly simple way of referencing the last argument passed to a script on the command line. This also requires indirect referencing. @@ -3202,7 +3214,7 @@ fi - When referencing a variable, it is generally advisable in + When referencing a variable, it is generally advisable to enclose it in double quotes (" "). This preserves all special characters within the variable name, except $, ` (backquote), @@ -3499,7 +3511,12 @@ echo "\"Hello\", he said." # "Hello", he said. double backslash gives the backslash its literal meaning - echo "\\" # results in \ + echo "\\" # Results in \ + +# Whereas . . . + +echo "\" # Invokes secondary prompt from the command line. + # In a script, gives an error message. @@ -3649,7 +3666,7 @@ echo echo 'foo\ bar' # Escape character \ taken literally because of strong quoting. -#foor\ +#foo\ #bar # Examples suggested by Stephane Chazelas. @@ -4532,12 +4549,12 @@ home=/home/bozo - arithmetic and string comparisons + Arithmetic and string comparisons &ex13; - testing whether a string is <emphasis>null</emphasis> + Testing whether a string is <emphasis>null</emphasis> &strtest; @@ -5499,9 +5516,9 @@ done $EUID - effective user id + effective user ID - effective user id number + effective user ID number Identification number of whatever identity the current user has assumed, perhaps by means of su. @@ -6040,8 +6057,10 @@ echo "Last command argument processed = $last_cmd_arg" prompt secondary - The secondary prompt, seen when additional input is - expected. It displays as >. + + + The secondary prompt, seen when additional input is + expected. It displays as >. @@ -6269,9 +6288,9 @@ echo "Last command argument processed = $last_cmd_arg" $UID - user id + user ID - user id number + user ID number current user's user identification number, as recorded in /etc/passwd @@ -6529,7 +6548,7 @@ echo "$@" # 3 4 5 - PID (process id) of last job run in background + PID (process ID) of last job run in background LOG=$0.log @@ -6573,7 +6592,7 @@ echo $! >> "$LOG" - underscore variable + Underscore variable #!/bin/bash echo $_ # /bin/bash @@ -6621,7 +6640,7 @@ echo $_ # : PID of script - Process id of the script itself. The + Process ID of the script itself. The $$ variable often finds use in scripts to construct unique temp file names (see , + # Three characters of substring. + + + +# Is it possible to index from the right end of the string? + +echo ${stringZ:-4} # abcABC123ABCabc +# Defaults to full string, as in ${parameter:-default}. +# However . . . + +echo ${stringZ:(-4)} # Cabc +echo ${stringZ: -4} # Cabc +# Now, it works. +# Parentheses or added space "escape" the position parameter. + +# Thank you, Dan Jacobson, for pointing this out. If the $string parameter is * or @@ -9159,7 +9193,7 @@ done - <quote>unsetting</quote> a variable + <quote>Unsetting</quote> a variable &uns; @@ -10073,7 +10107,7 @@ wait - Job Identifiers + Job identifiers @@ -12695,7 +12729,7 @@ tr -d 0-9 <filename - stripping comments from C program files + Stripping comments from C program files &stripc; @@ -13309,7 +13343,7 @@ gzip -cd patchXX.gz | patch -p0 original binaries. - uudecoding encoded files + Uudecoding encoded files &ex52; @@ -15113,6 +15147,28 @@ esac + + + dialog + + dialog + + + command + dialog + + + The dialog family of tools + provide a method of calling interactive + dialog boxes from a script. The more + elaborate variations of dialog -- + gdialog, Xdialog, + and kdialog -- actually invoke X-Windows + widgets. See . + + + + @@ -15568,7 +15624,7 @@ exit 0 it carefully. - setting an erase character + Setting an erase character &erase; @@ -17888,7 +17944,7 @@ textfile_listing=`ls *.txt` echo $textfile_listing textfile_listing2=$(ls *.txt) # The alternative form of command substitution. -echo $textfile_listing +echo $textfile_listing2 # Same result. # A possible problem with putting a list of files into a single string @@ -18566,13 +18622,13 @@ exec 3>&- # Now close it for the remainder of the s of I/O redirection to feed a command list to an interactive program or command, such as ftp, telnet, or ex. - A limit string delineates (frames) the command - list. The special symbol << designates the limit - string. This has the effect of redirecting the output of a file - into the program, similar to interactive-program < - command-file, where command-file - contains + linkend="telnetref">telnet, or ex. A + limit string delineates (frames) the command list. + The special symbol << designates the limit string. + This has the effect of redirecting the output of a file into the + stdin of the program or command. It is similar + to interactive-program < command-file, + where command-file contains command #1 command #2 ... @@ -18632,27 +18688,35 @@ LimitString &ex71b; + This is a useful script containing a here document with + parameter substitution. + + + Upload a file pair to <quote>Sunsite</quote> incoming + directory + &ex72; + + Quoting or escaping the limit string at the head of a here document disables parameter substitution within its - body. This has very limited usefulness. + body. Parameter substitution turned off &ex71c; + + Disabling parameter substitution permits outputting literal text. + Generating scripts or even program code is one use for this. - - This is a useful script containing a here document with - parameter substitution. - - - <command>upload</command>: Uploads a file pair to <quote>Sunsite</quote> - incoming directory - &ex72; + + A script that generates another script + &generatescript; + A here document can supply input to a function in the same script. @@ -18711,6 +18775,42 @@ exit 0 Some utilities will not work inside a here document. + + + + The closing limit string, + on the final line of a here document, must start in the + first character position. There can be + no leading whitespace. + + + + + #!/bin/bash + +echo "----------------------------------------------------------------------" + +cat <<LimitString +echo "This is line 1 of the message inside the here document." +echo "This is line 2 of the message inside the here document." +echo "This is the final line of the message inside the here document." + LimitString +#^^^^Indented limit string. Error! This script will not behave as expected. + +echo "----------------------------------------------------------------------" + +# These comments are outside the 'here document', +#+ and should not echo. + +echo "Outside the here document." + +exit 0 + +echo "This line had better not echo." # Follows an 'exit' command. + + + + For those tasks too complex for a here document, consider using the expect scripting language, which is specifically tailored for feeding @@ -19856,7 +19956,10 @@ done < <(route -n) route -n | while read des what mask iface; do # Variables set from output of pipe. echo $des $what $mask $iface - done # Same output as above. + done # This yields the same output as above. + # However, as Ulrich Gayer points out . . . + #+ this simplified equivalent uses a subshell for the while loop, + #+ and therefore the variables disappear when the pipe terminates. @@ -21541,7 +21644,7 @@ trap 'echo "Control-C disabled."' 2 specified in either abbreviated form or by complete name.
- bash options + Bash options @@ -21859,6 +21962,11 @@ exit 0 access to all the Bash-specific extensions should start with #!/bin/bash. + Putting whitespace in front of + the terminating limit string of a here document will cause unexpected + behavior in a script. + A script may not export variables back to its parent process, the shell, or to the environment. Just as we learned in biology, a child @@ -22455,7 +22563,7 @@ test "$city" \< Paris && echo "Yes, Paris is greater than $city" # Greater ASCI terminal emulators.
- Numbers Representing Colors in Escape Sequences + Numbers representing colors in Escape Sequences @@ -23023,7 +23131,21 @@ fi (and, in fact, segfault). - For more effective scripting with widgets, try + + + The dialog family of tools offers a method + of calling dialog widgets from a shell script. The + original dialog utility works in a text + console, but its successors, gdialog, + Xdialog, and kdialog + use X-Windows-based widget sets. + + + <command>Widgets invoked from a shell script</command> + &dialog; + + + For other methods of scripting with widgets, try Tk or wish (Tcl derivatives), PerlTk (Perl with Tk extensions), @@ -23423,7 +23545,8 @@ fi Thrysoee, Adam Lazur, Bram Moolenaar, Baris Cicek, Greg Keraunen, Keith Matthews, Sandro Magi, Albert Reiner, Dim Segebart, Rory Winston, Lee Bigelow, Wayne Pollock, jipe, - Emilio Conti, Dennis Leeuw, and David Lawyer (himself an author + Emilio Conti, Dennis Leeuw, Dan Jacobson, Aurelio Marinho Jargas, + Edward Scholtz, Jean Helou, and David Lawyer (himself an author of 4 HOWTOs). My gratitude to Chet @@ -23436,6 +23559,11 @@ fi and lore, and has, to a large extent, enabled the publication of this book. + Thanks and appreciation to IBM, Red Hat, the Free Software Foundation, and + all the good people fighting the good fight to keep Open Source + software free and open. + Thanks most of all to my wife, Anita, for her encouragement and emotional support. @@ -23818,6 +23946,11 @@ fi + + Fioretti, Marco, Scripting for X + Productivity, LINUX JOURNAL, Issue 113, September, 2003, pp. + 86-9. + @@ -23977,6 +24110,16 @@ fi + + + Aurelio Marinho Jargas has written a Regular expression + wizard. He has also written an informative book on Regular Expressions, + in Portuguese. + + + Rocky Bernstein is in the process of developing a @@ -24194,6 +24337,532 @@ fi + + + Reference Cards + + +
+ Special Shell Variables + + + + Variable + Meaning + + + + + + Name of script + + + + Positional parameter #1 + + + + Positional parameters #2 - #9 + + + + Positional parameter #10 + + + + Number of positional parameters + + + + All the positional parameters (as a single word) + + + + All the positional parameters (as separate strings) + + + + Number of command line parameters passed to + script + + + + Number of command line parameters passed to + script + + + + Return value + + + + Process ID (PID) of script + + + + Flags passed to script (using + set) + + + + Last argument of previous command + + + + Process ID (PID) of last job run in background + + + +
+ + + + + TEST Operators: Binary Comparison + + + + Operator + Meaning + ----- + Operator + Meaning + + + + + + + + + Arithmetic Comparison + + + String Comparison + + + + + Equal to + + + Equal to + + + + + + + Equal to + + + + Not equal to + + + Not equal to + + + + Less than + + + Less than (ASCII) * + + + + Less than or equal to + + + + + + Greater than + + + Greater than (ASCII) * + + + + Greater than or equal to + + + + + + + + + String is empty + + + + + + + String is not empty + + + + + + + Arithmetic Comparison + within double parentheses (( ... )) + + + + Greater than + + + + Greater than or equal to + + + + Less than + + + + Less than or equal to + + + +
+ + + * If within a + double-bracket [[ ... ]] test construct, + then no escape \ is + needed. + + + TEST Operators: Files + + + + Operator + Tests Whether + ----- + Operator + Tests Whether + + + + + + File exists + + + File is not zero size + + + + File is a regular file + + + + File is a directory + + + File has read + permission + + + + File is a symbolic link + + + File has write + permission + + + + File is a symbolic link + + + File has execute + permission + + + + File is a block device + + + + File is a character device + + + sgid flag set + + + + File is a pipe + + + suid flag set + + + + File is a socket + + + sticky bit set + + + + File is associated with a + terminal + + + + + File modified since it was last read + + + File F1 is newer than F2 * + + + + You own the file + + + File F1 is older than F2 * + + + + Group id of file same as + yours + + + Files F1 and F2 are hard links + to the same file * + + + + + NOT (reverses sense of above + tests) + + + +
+ + + * Binary operator + (requires two operands). + + + + + + Parameter Substitution and Expansion + + + + Expression + Meaning + + + + + + Value of var, same as + $var + + + + If var not set, evaluate expression + as $DEFAULT * + + + + If var not set, evaluate expression + as $DEFAULT * + + + + If var not set, evaluate expression + as $DEFAULT * + + + + If var not set, evaluate expression + as $DEFAULT * + + + + If var set, evaluate expression as + $OTHER, otherwise as null string + + + + If var set, evaluate expression as + $OTHER, otherwise as null string + + + + If var not set, print + $ERR_MSG * + + + + If var not set, print + $ERR_MSG * + + + +
+ + * Of course if var + is set, evaluate the expression as + $var. + + + + String Operations + + + + Expression + Meaning + + + + + + Length of $string + + + + + Extract substring from $string + at $position + + + + Extract $length + characters substring from $string + at $position + + + + + Strip shortest match of + $substring from front of + $string + + + + Strip longest match of + $substring from front of + $string + + + + Strip shortest match of + $substring from back of + $string + + + + Strip longest match of + $substring from back of + $string + + + + + Replace first match of + $substring with + $replacement + + + + Replace all matches of + $substring with + $replacement + + + + If $substring + matches front end of + $string, substitute + $replacement for + $substring + + + + If $substring + matches back end of + $string, substitute + $replacement for + $substring + + + + + + Length of matching $substring* + at beginning of $string + + + + Length of matching $substring* + at beginning of $string + + + + Numerical position in $string + of first character in $substring + that matches + + + + Extract $length characters + from $string starting at + $position + + + + Extract $substring* at + beginning of $string + + + + Extract $substring* at + beginning of $string + + + + Extract $substring* at + end of $string + + + + Extract $substring* at + end of $string + + + +
+ + * Where $substring is a + regular expression. + + + + + + + + + A Sed and Awk Micro-Primer @@ -24349,7 +25018,7 @@ pattern=BEGIN - Examples + Examples of sed operators @@ -25225,7 +25894,7 @@ history batch file into a shell script.
- DOS Commands and Their UNIX Equivalents + DOS commands and their UNIX equivalents @@ -26137,10 +26806,15 @@ fairly detailed rundown on the Playfair Cipher and its solution methods. Copyright - The Advanced Bash-Scripting Guide is copyright, - (c) 2000, by Mendel Cooper. This document may only be - distributed subject to the terms and conditions set forth in - the Open Publication License (version 1.0 or later), http://www.opencontent.org/openpub/. The following license options also apply. @@ -26152,11 +26826,13 @@ B. Distribution of the work or derivative of the work in any standard (paper) book form is prohibited unless prior permission is obtained from the copyright holder. - Provision A, above, explicitly prohibits the - insertion of company logos or navigation bars into the document, - but with the following exemptions. - - + Provision A, above, explicitly prohibits + relabeling this document. An example of + relabeling is the insertion of company logos or navigation bars + into the cover, title page, or the text. The author grants the + following exemptions. + + Non-profit organizations, such as the + Without explicit written permission from the author, + distributors and publishers (including on-line publishers) are + prohibited from imposing any additional conditions, strictures, + or provisions on this document or any previous version of it. As of + this update, the author asserts that he has not + entered into any contractual obligations that would alter the + foregoing declarations. + Essentially, you may freely distribute this book in unaltered electronic form. You must obtain the author's permission to distribute a substantially modified @@ -26178,29 +26862,26 @@ B. Distribution of the work or derivative of the work in any standard preserve the artistic integrity of this document and to prevent forking. + If you display or distribute this document or any previous + version thereof under any license except the one above, then you + are required to obtain the author's written permission. Failure + to do so may terminate your distribution rights. + These are very liberal terms, and they should not hinder any legitimate distribution or use of this book. The author especially - encourages the use of this book for instructional purposes. + encourages the use of this book for classroom and instructional + purposes. - The commercial print rights to this book are available. Please - contact the - author if interested. + The commercial print and other rights to this book are + available. Please contact the author if + interested. The author produced this book in a manner consistent with the spirit of the LDP Manifesto. - - Hyun Jin Cha has done a Korean - translation of version 1.0.11 of this book. Spanish, - Portuguese, French, German, Italian, and Chinese translations - are underway. If you wish to translate this document into another - language, please feel free to do so, subject to the terms stated - above. The author wishes to be notified of such efforts. - - Linux is a trademark registered to Linus Torvalds. Unix and UNIX are trademarks registered to the Open Group. @@ -26210,6 +26891,15 @@ B. Distribution of the work or derivative of the work in any standard + Hyun Jin Cha has done a Korean + translation of version 1.0.11 of this book. Spanish, + Portuguese, French, German, Italian, and Chinese translations + are underway. If you wish to translate this document into another + language, please feel free to do so, subject to the terms stated + above. The author wishes to be notified of such efforts. + + diff --git a/LDP/guide/docbook/abs-guide/encryptedpw.sh b/LDP/guide/docbook/abs-guide/encryptedpw.sh index 9a3ab40b..2feecd96 100644 --- a/LDP/guide/docbook/abs-guide/encryptedpw.sh +++ b/LDP/guide/docbook/abs-guide/encryptedpw.sh @@ -28,7 +28,7 @@ Password=`cruft <$pword` # Decrypt password. # Uses the author's own "cruft" file encryption package, #+ based on the classic "onetime pad" algorithm, #+ and obtainable from: -#+ Primary-site: ftp://metalab.unc.edu /pub/Linux/utils/file +#+ Primary-site: ftp://ibiblio.org/pub/Linux/utils/file #+ cruft-0.2.tar.gz [16k] diff --git a/LDP/guide/docbook/abs-guide/erase.sh b/LDP/guide/docbook/abs-guide/erase.sh index 8e1770a7..3431db8f 100644 --- a/LDP/guide/docbook/abs-guide/erase.sh +++ b/LDP/guide/docbook/abs-guide/erase.sh @@ -2,13 +2,14 @@ # erase.sh: Using "stty" to set an erase character when reading input. echo -n "What is your name? " -read name # Try to erase characters of input. - # Won't work. +read name # Try to backspace + #+ to erase characters of input. + # Won't work. echo "Your name is $name." -stty erase '#' # Set "hashmark" (#) as erase character. +stty erase '#' # Set "hashmark" (#) as erase character. echo -n "What is your name? " -read name # Use # to erase last character typed. +read name # Use # to erase last character typed. echo "Your name is $name." exit 0 diff --git a/LDP/guide/docbook/abs-guide/ex72.sh b/LDP/guide/docbook/abs-guide/ex72.sh index 4a42996b..dd7235d5 100644 --- a/LDP/guide/docbook/abs-guide/ex72.sh +++ b/LDP/guide/docbook/abs-guide/ex72.sh @@ -2,7 +2,7 @@ # upload.sh # Upload file pair (Filename.lsm, Filename.tar.gz) -# to incoming directory at Sunsite (metalab.unc.edu). +# to incoming directory at Sunsite (ibiblio.org). E_ARGERROR=65 @@ -15,7 +15,7 @@ fi Filename=`basename $1` # Strips pathname out of file name. -Server="metalab.unc.edu" +Server="ibiblio.org" Directory="/incoming/Linux" # These need not be hard-coded into script, # but may instead be changed to command line argument. diff --git a/LDP/guide/docbook/abs-guide/ex76.sh b/LDP/guide/docbook/abs-guide/ex76.sh index 0e9fd981..04f5b867 100644 --- a/LDP/guide/docbook/abs-guide/ex76.sh +++ b/LDP/guide/docbook/abs-guide/ex76.sh @@ -8,5 +8,5 @@ a=39 b=36 exit 0 -# Note that commenting out the 'exit' command makes no difference, -# since the script exits in any case after running out of commands. +# Note that commenting out the 'exit' command makes no difference, +#+ since the script exits in any case after running out of commands. diff --git a/LDP/guide/docbook/abs-guide/manview.sh b/LDP/guide/docbook/abs-guide/manview.sh index a8cbcb82..7d17afb9 100644 --- a/LDP/guide/docbook/abs-guide/manview.sh +++ b/LDP/guide/docbook/abs-guide/manview.sh @@ -15,9 +15,9 @@ fi groff -Tascii -man $1 | less # From the man page for groff. -# If the man page includes tables and/or equations, -# then the above code will barf. -# The following line can handle such cases. +# If the man page includes tables and/or equations, +#+ then the above code will barf. +# The following line can handle such cases. # # gtbl < "$1" | geqn -Tlatin1 | groff -Tlatin1 -mtty-char -man # diff --git a/LDP/guide/docbook/abs-guide/pb.sh b/LDP/guide/docbook/abs-guide/pb.sh index 6f9b9cbc..193a390a 100644 --- a/LDP/guide/docbook/abs-guide/pb.sh +++ b/LDP/guide/docbook/abs-guide/pb.sh @@ -33,7 +33,7 @@ John Doe 1555 Main St., Baltimore, MD 21228 (410) 222-3333 Mary Moe 9899 Jones Blvd., Warren, NH 03787 (603) 898-3232 Richard Roe 856 E. 7th St., New York, NY 10009 (212) 333-4567 Sam Roe 956 E. 8th St., New York, NY 10009 (212) 444-5678 -Zoe Zenobia 4481 N. Baker St., San Franciso, SF 94338 (415) 501-1631 +Zoe Zenobia 4481 N. Baker St., San Francisco, SF 94338 (415) 501-1631 # ------------------------------------------------------------------------ $bash pb.sh Roe diff --git a/LDP/guide/docbook/abs-guide/poem.sh b/LDP/guide/docbook/abs-guide/poem.sh index b2fdfd32..7e8ba296 100644 --- a/LDP/guide/docbook/abs-guide/poem.sh +++ b/LDP/guide/docbook/abs-guide/poem.sh @@ -1,5 +1,5 @@ #!/bin/bash -# poem.sh +# poem.sh: Pretty-prints one of the author's favorite poems. # Lines of the poem (single stanza). Line[1]="I do not know which to prefer," @@ -11,6 +11,7 @@ Line[5]="Or just after." # Attribution. Attrib[1]=" Wallace Stevens" Attrib[2]="\"Thirteen Ways of Looking at a Blackbird\"" +# Above poem is in the Public Domain (copyright expired). for index in 1 2 3 4 5 # Five lines. do diff --git a/LDP/guide/docbook/abs-guide/symlinks.sh b/LDP/guide/docbook/abs-guide/symlinks.sh index 211b9d22..cda702e5 100644 --- a/LDP/guide/docbook/abs-guide/symlinks.sh +++ b/LDP/guide/docbook/abs-guide/symlinks.sh @@ -30,3 +30,16 @@ done | sort # Otherwise file list is unsorted. # Even this will only pick up the first field of each argument. exit 0 + + +# Jean Helou proposes the following alternative: + +echo "symbolic links in directory \"$directory\"" +# Backup of the current IFS. One can never be too cautious. +OLDIFS=$IFS +IFS=: + +for file in $(find $directory -type l -printf "%p$IFS") +do # ^^^^^^^^^^^^^^^^ + echo "$file" + done|sort