|
|
|
@ -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 <Ctl-V><Ctl-J></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=$(<$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<>/dev/tcp/www.slashdot.org/80</userinput>
|
|
|
|
|
<prompt>bash$ </prompt><userinput>echo "GET / HTTP/1.0</userinput>
|
|
|
|
|
<prompt>> </prompt><userinput>" >&5"</userinput>
|
|
|
|
|
<prompt>bash$ </prompt><userinput>echo -e "GET / HTTP/1.0\n" >&5</userinput>
|
|
|
|
|
<prompt>bash$ </prompt><userinput>cat <&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ö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ö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>
|
|
|
|
|