This commit is contained in:
gferg 2004-07-12 13:08:16 +00:00
parent cfa04967c4
commit ae3ef22080
9 changed files with 1867 additions and 1512 deletions

View File

@ -6,6 +6,80 @@
http://personal.riverusers.com/~thegrendel/Change.log
------------------------------------------------------------------------
Version 2.8
Elderberry release, 07/11/04
1) In the introduction:
Added link to pdf version of the book.
2) In "Arithmetic Expansion" chapter:
Fixed typo -- missing parenthesis -- in inline example.
(Thank you, Thorsten Bonow.)
3) In "Special Characters" chapter:
Added material at "Ctl-D" entry.
Added material at "Ctl-K" entry.
Added material at "Ctl-U" entry.
(Thank you, Jeremy Impson.)
Added "Ctl-V" entry.
(Thank you, Jeremy Impson.)
Added "Ctl-W" entry.
(Thank you, Jeremy Impson.)
At "-" (redirection from/to stdin or stdout) entry:
Fixed comment in Alan Cox's example.
(Thank you, Ken Fuchs.)
4) In "Gotchas" chapter:
Added another alternative to Anthony Richardson's piping-loop example.
(Thank you, Wilbert Berendsen.)
5) In "Internal Commands and Builtins" chapter:
At "echo" entry, showed how to embed a linefeed within echoed text.
(Thanks, Steve Parker.)
At "read" entry, added note that "read -n" command sequence will not
detect the ENTER (newline) key.
(Thank you, Tony Morgan.)
At "source" entry, rewrote introductory paragraph for additional
clarity.
Added "bind" entry, with a brief footnote about the readline library.
Slight modification of discussion at "help" entry.
6) In "File and Archiving Commands" section of "External Commands" Chapter:
At "sum, cksum, md5sum" entry, added usage examples and expanded note.
7) In "List Constructs" chapter:
Added example snippets from Miquel van Smoorenburg's
/etc/rc.d/init.d/single script.
8) In "/dev" section of "/dev and /proc" chapter:
Fixed up "Downloading a URL" inline example.
(Thanks, Mihai Maties.)
Added "noatime" to USB flash drive installation example.
9) Cleaned up and made consistent notes about #!/bin/sh disabling extended
Bash functionality.
10) In "Exit Codes With Special Meanings" appendix:
Fixed footnote about out-of-range exit values.
11) In "Important System Directories" appendix:
Added /var and /boot entries.
Additional short notes.
Other Minor changes.
12) In the "Sed and Awk Micro-primer" appendix:
Corrected explanation of backslash in sed.
(Thank you, George Cristian Birzan.)
13) In "Bibliography" section:
Added entry for "The Linux USB subsystem."
14) Various minor changes to example scripts.
Version 2.7
Mulberry release, 04/18/04

View File

@ -322,8 +322,8 @@ Uncomment line below to generate index.
</affiliation>
</author>
<releaseinfo>2.7</releaseinfo>
<pubdate>18 April 2004</pubdate>
<releaseinfo>2.8</releaseinfo>
<pubdate>11 July 2004</pubdate>
<revhistory>
@ -368,12 +368,14 @@ Uncomment line below to generate index.
<para>This book is suitable for classroom use as a general
introduction to programming concepts.</para>
<para>The latest update of this document, as an archived, <link
<para><ulink
url="http://personal.riverusers.com/~thegrendel/abs-guide-2.8.tar.bz2">
The latest update of this document</ulink>, as an archived, <link
linkend="bzipref">bzip2-ed</link> <quote>tarball</quote>
including both the SGML source and
rendered HTML, may be downloaded from <ulink
url="http://personal.riverusers.com/~thegrendel/abs-guide-2.7.tar.bz2">
the author's home site</ulink>. See the <ulink
including both the SGML source and rendered HTML, may
be downloaded from the author's home site. A <ulink
url="http://www.tldp.org/LDP/abs/abs-guide.pdf">pdf
version</ulink> is also available. See the <ulink
url="http://personal.riverusers.com/~thegrendel/Change.log">change
log</ulink> for a revision history.</para>
@ -687,7 +689,7 @@ exit $WHATEVER # Doesn't matter. The script will not exit here.</programlisting
Using <userinput>#!/bin/sh</userinput>, the default Bourne shell
in most commercial variants of Unix, makes the script <link
linkend="portabilityissues">portable</link> to non-Linux machines,
though you may have to sacrifice a few Bash-specific features.
though you sacrifice Bash-specific features.
The script will, however, conform to the
<acronym>POSIX</acronym>
@ -781,7 +783,7 @@ fi</programlisting>
<userinput>scriptname</userinput>? If the directory
you are in (<link linkend="pwdref">$PWD</link>) is where
<emphasis>scriptname</emphasis> is located, why doesn't this
work? This fails because, for security reasons, the current
work? This fails because, for security reasons, the current
directory, <quote>.</quote> is not included in a user's <link
linkend="pathref">$PATH</link>. It is therefore necessary to
explicitly invoke the script in the current directory with
@ -2302,7 +2304,7 @@ fi</programlisting>
</varlistentry>
<varlistentry>
<term><token>-</token></term>
<term><anchor id="dashref2"><token>-</token></term>
<indexterm>
<primary>-</primary>
</indexterm>
@ -2342,10 +2344,10 @@ fi</programlisting>
# More elegant than, but equivalent to:
# cd source-directory
# tar cf - . | (cd ../target-directory; tar xzf -)
# cd source/directory
# tar cf - . | (cd ../dest/directory; tar xpvf -)
#
# cp -a /source/directory /dest also has same effect.
# cp -a /source/directory /dest/directory also has same effect.
</programlisting></para>
<para><programlisting>bunzip2 linux-2.4.3.tar.bz2 | tar xvf -
@ -2607,7 +2609,10 @@ echo $a # 28</programlisting></para>
terminal or text display.</title>
<para>A control character is a <keycap>CONTROL</keycap>
+ <keycap>key</keycap> combination.</para>
</formalpara>
</formalpara>
<para>Control characters are not normally useful inside a
script.</para>
<itemizedlist id="ctlchar">
@ -2622,12 +2627,18 @@ echo $a # 28</programlisting></para>
</listitem>
<listitem>
<para><anchor id="ctldref"></para>
<para><userinput>Ctl-D</userinput></para>
<para>Log out from a shell (similar to
<link linkend="exitcommandref">exit</link>).</para>
<para><quote>EOF</quote> (end of file). This also
terminates input from <filename>stdin</filename>.</para>
<para>When typing text on the console or in an xterm window,
<userinput>Ctl-D</userinput> erases the character under the
cursor. When there are no characters present,
<userinput>Ctl-D</userinput> logs out of the session, as
expected.</para>
</listitem>
<listitem>
@ -2666,6 +2677,9 @@ echo; echo</programlisting>
<listitem>
<para><userinput>Ctl-K</userinput></para>
<para>Vertical tab.</para>
<para>When typing text on the console or in an xterm window,
<userinput>Ctl-K</userinput> erases from the character
under the cursor to end of line.</para>
</listitem>
<listitem>
@ -2734,7 +2748,31 @@ exit 0</programlisting>
<listitem>
<para><userinput>Ctl-U</userinput></para>
<para>Erase a line of input.</para>
<para>Erase a line of input, from the cursor backward to
beginning of line. In some settings,
<userinput>Ctl-U</userinput> erases the entire
line of input, <emphasis>regardless of cursor
position</emphasis>.</para>
</listitem>
<listitem>
<para><userinput>Ctl-V</userinput></para>
<para>When inputting text, <userinput>Ctl-V</userinput>
permits inserting control characters. For example, the
following two are equivalent:
<programlisting>echo -e '\x0a'
echo &lt;Ctl-V&gt;&lt;Ctl-J&gt;</programlisting></para>
<para><userinput>Ctl-V</userinput> is primarily useful from
within a text editor.</para>
</listitem>
<listitem>
<para><userinput>Ctl-W</userinput></para>
<para>When typing text on the console or in an xterm window,
<userinput>Ctl-W</userinput> erases from the character
under the cursor backwards to the first instance of
whitespace. In some settings, <userinput>Ctl-W</userinput>
erases backwards to first non-alphanumeric character.</para>
</listitem>
<listitem>
@ -8897,6 +8935,54 @@ fi</programlisting></para>
</screen>
</para>
<para>
So, how can we embed a linefeed within an
<emphasis>echoed</emphasis> character string?
<programlisting># Embedding a linefeed?
echo "Why doesn't this string \n split on two lines?"
# Doesn't split.
# Let's try something else.
echo
echo $"A line of text containing
a linefeed."
# Prints as two distinct lines (embedded linefeed).
# But, is the "$" variable prefix really necessary?
echo
echo "This string splits
on two lines."
# No, the "$" is not needed.
echo
echo "---------------"
echo
echo -n $"Another line of text containing
a linefeed."
# Prints as two distinct lines (embedded linefeed).
# Even the -n option fails to suppress the linefeed here.
echo
echo
echo "---------------"
echo
echo
# However, the following doesn't work as expected.
# Why not?
string1=$"Yet another line of text containing
a linefeed (maybe)."
echo $string1
# Thanks, Steve Parker, for pointing this out.</programlisting>
</para>
<note>
<para>This command is a shell builtin, and not the same as
<filename>/bin/echo</filename>, although its behavior is
@ -9036,6 +9122,10 @@ echo; echo "Keypress was "\"$keypress\""."
<programlisting>&arrowdetect;</programlisting>
</example>
<note><para>The <option>-n</option> option to <command>read</command>
will not detect the <keycap>ENTER</keycap> (newline)
key.</para></note>
<para>The <option>-t</option> option to <command>read</command>
permits timed input (see <xref linkend="tout">).</para>
@ -9688,11 +9778,15 @@ shift $(($OPTIND - 1))
<para>This command, when invoked from the command line,
executes a script. Within a script, a
<userinput>source file-name</userinput> loads the file
<filename>file-name</filename>. This is the shell scripting
equivalent of a C/C++ <userinput>#include</userinput>
directive. It is useful in situations when multiple scripts
use a common data file or function library.</para>
<userinput>source file-name</userinput> loads the
file <filename>file-name</filename>. Sourcing a file
(dot-command) <emphasis>imports</emphasis>
code into the script, appending to the script (same
effect as the <userinput>#include</userinput> directive
in a C program). The net result is the same as if the
<quote>sourced</quote> lines of code were in the body of
the script. This is useful in situations when multiple
scripts use a common data file or function library.</para>
<example id="ex38">
<title><quote>Including</quote> a data file</title>
@ -9940,6 +10034,28 @@ done
</listitem>
</varlistentry>
<varlistentry>
<term><command>bind</command></term>
<indexterm>
<primary>bind</primary>
</indexterm>
<indexterm>
<primary>bind</primary>
<secondary>key bindings </secondary>
</indexterm>
<listitem>
<para>The <command>bind</command> builtin displays or modifies
<emphasis>readline</emphasis>
<footnote><para>The <emphasis>readline</emphasis> library
is what Bash uses for reading input in an interactive
shell.</para></footnote>
key bindings.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><command>help</command></term>
<indexterm>
@ -9951,8 +10067,7 @@ done
</indexterm>
<listitem>
<para><command>help</command> COMMAND looks up
a short usage summary of the shell builtin COMMAND. This is
<para>Gets a short usage summary of a shell builtin. This is
the counterpart to <link linkend="whatisref">whatis</link>,
but for builtins.</para>
@ -10423,7 +10538,7 @@ wait</programlisting>
to underestimate the power of this humble command. For
example, using the <option>-R</option>, recursive option,
<command>ls</command> provides a tree-like listing of
a directory structure. Other interesting options are
a directory structure. Other useful options are
<option>-S</option>, sort listing by file size,
<option>-t</option>, sort by file modification time, and
<option>-i</option>, show file inodes (see <xref
@ -13679,15 +13794,28 @@ gzip -cd patchXX.gz | patch -p0
<prompt>bash$ </prompt><userinput>cksum /boot/vmlinuz</userinput>
<computeroutput>1670054224 804083 /boot/vmlinuz</computeroutput>
<prompt>bash$ </prompt><userinput>echo -n "Top Secret" | cksum</userinput>
<computeroutput>3391003827 10</computeroutput>
<prompt>bash$ </prompt><userinput>md5sum /boot/vmlinuz</userinput>
<computeroutput>0f43eccea8f09e0a0b2b5cf1dcf333ba /boot/vmlinuz</computeroutput>
<prompt>bash$ </prompt><userinput>echo -n "Top Secret" | md5sum</userinput>
<computeroutput>8babc97a6f62a4649716f4df8d61728f -</computeroutput>
</screen>
</para>
<para>Note that <command>cksum</command> also shows the size,
in bytes, of the target file.</para>
<note>
<para>The <command>cksum</command> command shows the size,
in bytes, of its target, whether file or
<filename>stdout</filename>.</para>
<para>The <command>md5sum</command> command displays a
<link linkend="dashref2">dash</link> when it receives its input from
<filename>stdout</filename>.</para>
</note>
<example id="fileintegrity">
<title>Checking file integrity</title>
@ -18934,7 +19062,7 @@ File_contents2=$(&lt;$file2) # Bash permits this also.</programlisting></
<para>
<programlisting>z=$(($z+3))
z=$((z+3) # Also correct.
z=$((z+3)) # Also correct.
# Within double parentheses,
#+ parameter dereferencing
#+ is optional.
@ -21460,6 +21588,8 @@ drwxr-xr-x 40 bozo bozo 2048 Feb 6 14:04 ..
<returnvalue>false</returnvalue> is the last one to
execute).</para>
<example id="ex64">
<title>Using an <quote>and list</quote> to test for command-line arguments</title>
<programlisting>&ex64;</programlisting>
@ -21509,6 +21639,38 @@ drwxr-xr-x 40 bozo bozo 2048 Feb 6 14:04 ..
</variablelist>
<para><programlisting># ==> The following snippets from the /etc/rc.d/init.d/single script by Miquel van Smoorenburg
#+==> illustrate use of "and" and "or" lists.
# ==> "Arrowed" comments added by document author.
[ -x /usr/bin/clear ] && /usr/bin/clear
# ==> If /usr/bin/clear exists, then invoke it.
# ==> Checking for the existence of a command before calling it
#+==> avoids error messages and other awkward consequences.
# ==> . . .
# If they want to run something in single user mode, might as well run it...
for i in /etc/rc1.d/S[0-9][0-9]* ; do
# Check if the script is there.
[ -x "$i" ] || continue
# ==> If corresponding file in $PWD *not* found,
#+==> then "continue" by jumping to the top of the loop.
# Reject backup files and files generated by rpm.
case "$1" in
*.rpmsave|*.rpmorig|*.rpmnew|*~|*.orig)
continue;;
esac
[ "$i" = "/etc/rc1.d/S00single" ] && continue
# ==> Set script name, but don't execute it yet.
$i start
done
# ==> . . .</programlisting></para>
<important><para>The <link linkend="exitstatusref">exit
status</link> of an <userinput>and list</userinput> or an
<userinput>or list</userinput> is the exit status of the last
@ -21988,7 +22150,7 @@ exit 0</programlisting></para>
<command>mount /mnt/flashdrive</command></para>
</footnote>
<programlisting>/dev/sda1 /mnt/flashdrive auto noauto,user 0 0</programlisting>
<programlisting>/dev/sda1 /mnt/flashdrive auto noauto,user,noatime 0 0</programlisting>
(See also <xref linkend="usbinst">.)</para>
@ -22013,14 +22175,16 @@ exit 0</programlisting></para>
<computeroutput>53082 04-03-18 04:26:54 68 0 0 502.3 UTC(NIST) *</computeroutput>
</screen>
<para>[Mark contributed the above example.]</para>
<para>Downloading a URL:</para>
<screen><prompt>bash$ </prompt><userinput>exec 5&lt;&gt;/dev/tcp/www.slashdot.org/80</userinput>
<prompt>bash$ </prompt><userinput>echo "GET / HTTP/1.0</userinput>
<prompt>&gt; </prompt><userinput>" &gt;&5"</userinput>
<prompt>bash$ </prompt><userinput>echo -e "GET / HTTP/1.0\n" >&5</userinput>
<prompt>bash$ </prompt><userinput>cat &lt;&5</userinput>
</screen>
<para>[Mark contributed the last two examples.]</para>
<para>[Thanks, Mark and Mihai Maties.]</para>
@ -22948,7 +23112,7 @@ exit 0</programlisting>
</para>
<para>A shell script headed by <userinput>#!/bin/sh</userinput>
may not run in full Bash-compatibility mode. Some Bash-specific
will not run in full Bash-compatibility mode. Some Bash-specific
functions might be disabled. Scripts that need complete
access to all the Bash-specific extensions should start with
<userinput>#!/bin/bash</userinput>.</para>
@ -23001,7 +23165,8 @@ exit 0</programlisting>
<para>
<programlisting># Loop piping troubles.
# This example by Anthony Richardson.
# This example by Anthony Richardson,
#+ with addendum by Wilbert Berendsen.
foundone=false
@ -23034,7 +23199,28 @@ done
if [ $foundone = false ]
then
echo "No files need archiving."
fi</programlisting>
fi
# ==================And here is another alternative==================
# Places the part of the script that reads the variables
#+ within a code block, so they share the same subshell.
# Thank you, W.B.
find $HOME -type f -atime +30 -size 100k | {
foundone=false
while read f
do
echo "$f is over 100KB and has not been accessed in over 30 days"
echo "Consider moving the file to archives."
foundone=true
done
if ! $foundone
then
echo "No files need archiving."
fi
}</programlisting>
</para>
<para>
@ -24299,9 +24485,10 @@ fi
<programlisting>#!/bin/sh</programlisting>
header in the script, rather than
<programlisting>#!/bin/bash</programlisting>
Of course, <filename>/bin/sh</filename> is a <link
Note that <filename>/bin/sh</filename> is a <link
linkend="linkref">link</link> to <filename>/bin/bash</filename>
in Linux and certain other flavors of UNIX.</para>
in Linux and certain other flavors of UNIX, and a script invoked
this way disables extended Bash funtionality.</para>
<para>Most Bash scripts will run as-is under
<command>ksh</command>, and vice-versa, since Chet Ramey has
@ -24659,19 +24846,20 @@ fi
errors and other corrections. Special thanks!</para>
<para>Others contributing scripts, making helpful suggestions, and
pointing out errors were Gabor Kiss, Leopold Toetsch, Peter
Tillier, Marcus Berglof, Tony Richardson, Nick Drage (script
ideas!), Rich Bartell, Jess Thrysoee, Adam Lazur, Bram Moolenaar,
Baris Cicek, Greg Keraunen, Keith Matthews, Sandro Magi,
Albert Reiner, Dim Segebart, Rory Winston, Lee Bigelow, Wayne
Pollock, <quote>jipe,</quote> <quote>Mark,</quote> Emilio Conti,
Ian. D. Allen, Arun Giridhar, Dennis Leeuw, Dan Jacobson, Aurelio
Marinho Jargas, Edward Scholtz, Jean Helou, Chris Martin, Lee
Maschmeyer, Bruno Haible, Sebastien Godard, Bj&ouml;n Eriksson,
<quote>nyal,</quote> John MacDonald, Joshua Tschida, Troy Engel,
Manfred Schwarb, Amit Singh, Bill Gradwohl, David Lombard,
Jason Parker, Bruce W. Clare, William Park, Vernia Damiano,
and David Lawyer (himself an author of four HOWTOs).</para>
pointing out errors were Gabor Kiss, Leopold Toetsch,
Peter Tillier, Marcus Berglof, Tony Richardson, Nick Drage
(script ideas!), Rich Bartell, Jess Thrysoee, Adam Lazur, Bram
Moolenaar, Baris Cicek, Greg Keraunen, Keith Matthews, Sandro
Magi, Albert Reiner, Dim Segebart, Rory Winston, Lee Bigelow,
Wayne Pollock, <quote>jipe,</quote> <quote>Mark,</quote> Emilio
Conti, Ian. D. Allen, Arun Giridhar, Dennis Leeuw, Dan Jacobson,
Aurelio Marinho Jargas, Edward Scholtz, Jean Helou, Chris Martin,
Lee Maschmeyer, Bruno Haible, Wilbert Berendsen, Sebastien Godard,
Bj&ouml;n Eriksson, <quote>nyal,</quote> John MacDonald, Joshua
Tschida, Troy Engel, Manfred Schwarb, Amit Singh, Bill Gradwohl,
David Lombard, Jason Parker, Steve Parker, Bruce W. Clare,
William Park, Vernia Damiano, Mihai Maties, Jeremy Impson, Ken
Fuchs, and David Lawyer (himself an author of four HOWTOs).</para>
<para>My gratitude to <ulink url="mailto:chet@po.cwru.edu">Chet
Ramey</ulink> and Brian Fox for writing <command>Bash</command>,
@ -25252,6 +25440,14 @@ fi
</abstract>
</biblioentry>
<biblioentry>
<abstract>
<para><ulink url="http://www.linux-usb.org/USB-guide/book1.html">The
Linux USB subsystem</ulink> (helpful in writing scripts affecting
USB peripherals).</para>
</abstract>
</biblioentry>
<biblioentry>
<abstract>
<para>There is some nice material on <link
@ -25296,7 +25492,8 @@ fi
<para><ulink url="mailto:opengeometry@yahoo.ca">William Park</ulink>
is working on a <ulink
url="http://home.eol.ca/~parkw/index.html">project</ulink> to
incorporate certain Awk and Python features into Bash.</para>
incorporate certain Awk and Python features into Bash. Among
these is a <emphasis>gdbm</emphasis> interface.</para>
</abstract>
</biblioentry>
@ -26460,14 +26657,17 @@ pattern=BEGIN
results in
<screen><computeroutput>The most important parts of any application are its and sound effects</computeroutput></screen></para>
<para>The backslash represents a <emphasis>newline</emphasis> as a
substitution character. In this special case, the replacement
expression continues on the next line.
<para>A backslash forces the <command>sed</command> replacement
command to continue on to the next line. This has the effect of
using the <emphasis>newline</emphasis> at the end of the first
line as the <emphasis>replacement string</emphasis>.
<programlisting>s/^ */\
/g</programlisting>
This substitution replaces line-beginning spaces with a
newline. The net result is to replace paragraph indents with
a blank line between paragraphs.</para>
newline. The net result is to replace paragraph indents with a
blank line between paragraphs.</para>
<para>An address range followed by one or more operations may require
open and closed curly brackets, with appropriate newlines.
@ -26643,7 +26843,7 @@ awk '{print $1 $5 $6}' $filename
<entry>invalid argument to <link linkend="exitcommandref">exit</link></entry>
<entry>exit 3.14159</entry>
<entry><command>exit</command> takes only integer args in the
range 0 - 255</entry>
range 0 - 255 (see footnote)</entry>
</row>
<row>
<entry><option>128+n</option></entry>
@ -26672,9 +26872,10 @@ awk '{print $1 $5 $6}' $filename
<para>According to the table, exit codes 1 - 2, 126 - 165, and 255
<footnote><para>Out of range exit values can result in
unpredictable exit codes. For example,
<command>exit 3809</command> gives an exit code of
<errorcode>225</errorcode>.</para></footnote>
unexpected exit codes. An exit value greater than 255 returns an
exit code modulo 256. For example, <command>exit 3809</command>
gives an exit code of <errorcode>225</errorcode> (3809 % 256 =
225).</para></footnote>
have special meanings, and should therefore be avoided as
user-specified exit parameters. Ending a script with <command>exit
@ -26984,8 +27185,8 @@ exit 0</programlisting>
<listitem>
<para><filename class="directory">/bin</filename></para>
<para>Binary executables. Basic system programs and utilities
(such as <command>bash</command>).</para>
<para>Binaries (executables). Basic system programs
and utilities (such as <command>bash</command>).</para>
</listitem>
<listitem>
@ -26995,7 +27196,7 @@ exit 0</programlisting>
<para>Some early Unix systems had a fast, small-capacity fixed
disk (containing <filename class="directory">/</filename>,
the root partition), and a second drive which
was larger but slower (containing <filename
was larger, but slower (containing <filename
class="directory">/usr</filename> and other
partitions). The most frequently used programs and
utilities therefore resided on the small-but-fast
@ -27012,25 +27213,25 @@ exit 0</programlisting>
</para>
<para>More system executables.</para>
<para>More system binaries.</para>
</listitem>
<listitem>
<para><filename class="directory">/usr/local/bin</filename></para>
<para>Miscellaneous executables.</para>
<para>Miscellaneous binaries local to the particular machine.</para>
</listitem>
<listitem>
<para><filename class="directory">/sbin</filename></para>
<para>Superuser binaries. Basic system administrative programs
<para>System binaries. Basic system administrative programs
and utilities (such as <command>fsck</command>).</para>
</listitem>
<listitem>
<para><filename class="directory">/usr/sbin</filename></para>
<para>More superuser binaries.</para>
<para>More system administrative programs and utilities.</para>
</listitem>
<listitem>
@ -27050,11 +27251,31 @@ exit 0</programlisting>
<para>Documentation for installed packages.</para>
</listitem>
<listitem>
<para><filename class="directory">/usr/man</filename></para>
<para>The systemwide manpages.</para>
</listitem>
<listitem>
<para><filename class="directory">/tmp</filename></para>
<para>System temporary files.</para>
</listitem>
<listitem>
<para><filename class="directory">/sys</filename></para>
<para>Systemwide process directory. Contains information and
statistics about running processes. This is newly added to Linux
with the 2.6.X kernels.</para>
</listitem>
<listitem>
<para><filename class="directory">/var</filename></para>
<para><emphasis>Variable</emphasis> (changeable) system
files. This is a catchall <quote>scratchpad</quote>
directory for data generated while a Linux/UNIX machine
is running.</para>
</listitem>
<listitem>
<para><filename class="directory">/var/log</filename></para>
<para>Systemwide log files.</para>
@ -27065,6 +27286,24 @@ exit 0</programlisting>
<para>User mail spool.</para>
</listitem>
<listitem>
<para><filename class="directory">/lib</filename></para>
<para>Systemwide library files.</para>
</listitem>
<listitem>
<para><filename class="directory">/usr/lib</filename></para>
<para>More systemwide library files.</para>
</listitem>
<listitem>
<para><filename class="directory">/boot</filename></para>
<para>System <emphasis>boot</emphasis> directory. The kernel,
module links, system map, and boot manager reside here.</para>
<warning><para>Altering files in this directory may result in an
unbootable system.</para></warning>
</listitem>
</itemizedlist>
</appendix>
@ -28690,6 +28929,11 @@ fairly detailed rundown on the Playfair Cipher and its solution methods.</progra
<entry>18 Apr 2004</entry>
<entry>MULBERRY release: Minor update.</entry>
</row>
<row>
<entry><option>2.8</option></entry>
<entry>11 Jul 2004</entry>
<entry>ELDERBERRY release: Minor update.</entry>
</row>
</tbody>
</tgroup>
</table>

View File

@ -1,11 +1,15 @@
#!/bin/bash
until [ "$var1" = end ] # Tests condition here, at top of loop.
END_CONDITION=end
until [ "$var1" = "$END_CONDITION" ]
# Tests condition here, at top of loop.
do
echo "Input variable #1 "
echo "(end to exit)"
echo "($END_CONDITION to exit)"
read var1
echo "variable #1 = $var1"
echo
done
exit 0

View File

@ -8,13 +8,13 @@ case "$Keypress" in
[A-Z] ) echo "Uppercase letter";;
[0-9] ) echo "Digit";;
* ) echo "Punctuation, whitespace, or other";;
esac # Allows ranges of characters in [square brackets].
esac # Allows ranges of characters in [square brackets].
# Exercise:
# --------
# As the script stands, # it accepts a single keystroke, then terminates.
# Change the script so it accepts continuous input,
# reports on each keystroke, and terminates only when "X" is hit.
# Hint: enclose everything in a "while" loop.
# Exercise:
# --------
# As the script stands, it accepts a single keystroke, then terminates.
# Change the script so it accepts continuous input,
#+ reports on each keystroke, and terminates only when "X" is hit.
# Hint: enclose everything in a "while" loop.
exit 0

View File

@ -1,7 +1,5 @@
#!/bin/bash
# Creating a swapfile.
# This script must be run as root.
ROOT_UID=0 # Root has $UID 0.
E_WRONG_USER=65 # Not root?
@ -11,6 +9,8 @@ BLOCKSIZE=1024
MINBLOCKS=40
SUCCESS=0
# This script must be run as root.
if [ "$UID" -ne "$ROOT_UID" ]
then
echo; echo "You must be root to run this script."; echo

View File

@ -2,7 +2,7 @@
# May need to be invoked with #!/bin/bash2 on older machines.
# Cards:
# deals four random hands from a deck of cards.
# Deals four random hands from a deck of cards.
UNPICKED=0
PICKED=1
@ -17,9 +17,9 @@ CARDS=52
declare -a Deck
declare -a Suits
declare -a Cards
# It would have been easier and more intuitive
# with a single, 3-dimensional array.
# Perhaps a future version of Bash will support multidimensional arrays.
# It would have been easier and more intuitive
#+ with a single, 3-dimensional array.
# Perhaps a future version of Bash will support multidimensional arrays.
initialize_Deck ()
@ -73,7 +73,7 @@ printf %-4s $Card
}
seed_random () # Seed random number generator.
{
{ # What happens if you don't do this?
seed=`eval date +%s`
let "seed %= 32766"
RANDOM=$seed
@ -94,7 +94,7 @@ do
parse_card $t
u=$cards_picked+1
# Change back to 1-based indexing (temporarily).
# Change back to 1-based indexing (temporarily). Why?
let "u %= $CARDS_IN_SUIT"
if [ "$u" -eq 0 ] # Nested if/then condition test.
then
@ -114,7 +114,7 @@ return 0
# Structured programming:
# entire program logic modularized in functions.
# Entire program logic modularized in functions.
#================
seed_random
@ -122,9 +122,9 @@ initialize_Deck
initialize_Suits
initialize_Cards
deal_cards
#================
exit 0
#================
@ -132,7 +132,7 @@ exit 0
# Add comments to thoroughly document this script.
# Exercise 2:
# Revise the script to print out each hand sorted in suits.
# Add a routine (function) to print out each hand sorted in suits.
# You may add other bells and whistles if you like.
# Exercise 3:

View File

@ -4023,7 +4023,7 @@ scanner device on a system running Linux. </Para>
Scientific-Computing-with-GNU-Linux</ULink>,
<CiteTitle>Scientific Computing with Free GNU/Linux Software HOWTO</CiteTitle>
</Para><Para>
<CiteTitle>Updated: Nov 2003</CiteTitle>.
<CiteTitle>Updated: Jun 2004</CiteTitle>.
Aims to show how a PC running GNU/Linux can be used for
scientific computing. It lists the various available free
software and also links on the world wide web to tutorials

View File

@ -420,7 +420,7 @@ software from John-Paul Roubelat, F6FBB. </Para>
Scientific-Computing-with-GNU-Linux</ULink>,
<CiteTitle>Scientific Computing with Free GNU/Linux Software HOWTO</CiteTitle>
</Para><Para>
<CiteTitle>Updated: Nov 2003</CiteTitle>.
<CiteTitle>Updated: Jun 2004</CiteTitle>.
Aims to show how a PC running GNU/Linux can be used for
scientific computing. It lists the various available free
software and also links on the world wide web to tutorials

File diff suppressed because it is too large Load Diff