mirror of https://github.com/tLDP/LDP
updated
This commit is contained in:
parent
2e40af0c0f
commit
8f64a41334
|
@ -3,19 +3,89 @@
|
||||||
Release History
|
Release History
|
||||||
|
|
||||||
The latest version of this file is available on-line at
|
The latest version of this file is available on-line at
|
||||||
http://http://bash.webofcrafts.net/Change.log
|
http://http://bash.deta.in/Change.log
|
||||||
|
|
||||||
|
|
||||||
==================================================================
|
==================================================================
|
||||||
Current version = 6.4
|
Current version = 6.5
|
||||||
Dated 08/30/11
|
Dated 04/05/12
|
||||||
|
|
||||||
http://bash.webofcrafts.net/abs-guide-latest.tar.bz2
|
http://bash.deta.in/abs-guide-latest.tar.bz2
|
||||||
http://bash.webofcrafts.net/abs-guide.pdf
|
http://bash.deta.in/abs-guide.pdf
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
News: Version 6.4 released!
|
News: Version 6.5 released!
|
||||||
====================================================================
|
====================================================================
|
||||||
|
|
||||||
|
Version 6.5, Vortexberry* release
|
||||||
|
05 April 2012
|
||||||
|
|
||||||
|
* No such thing, but there most certainly ought to be.
|
||||||
|
Imagine a genetically engineered berry containing metallic
|
||||||
|
fibers which could be used as filaments in incandescent lightbulbs.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
1) In "Bash, versions 2, 3, and 4" chapter,
|
||||||
|
In the Version 3.0 section,
|
||||||
|
At the Extended Brace Expansion discussion,
|
||||||
|
Added "eval" workaround for parameterization.
|
||||||
|
(Thank you, Emiliano G.!)
|
||||||
|
|
||||||
|
2) In "Special Characters" chapter,
|
||||||
|
Fixed missing parenthesis at "pipe" entry.
|
||||||
|
(Thank you, Adamas, for pointing this out.)
|
||||||
|
|
||||||
|
3) In "Internal Commands and Builtins" chapter,
|
||||||
|
At "let" entry,
|
||||||
|
added Jeff Gorak's correction to the return value "anomaly."
|
||||||
|
|
||||||
|
4) At references to "trinary" operator, noted the somewhat more common
|
||||||
|
"ternary" usage.
|
||||||
|
|
||||||
|
5) In "External Commands" chapter:
|
||||||
|
In "Miscellaneous Commands" section,
|
||||||
|
At "dd" entry, added creating bootable flash drives example.
|
||||||
|
|
||||||
|
6) In "System and Administrative Commands" chapter,
|
||||||
|
In "Filesystem" subsection,
|
||||||
|
Added "mkdosfs" entry.
|
||||||
|
In "Miscellaneous" subsection,
|
||||||
|
Added "xrandr" entry and "backlight.sh" example script.
|
||||||
|
|
||||||
|
7) In the Bibliography, added "AuctionGallery" entry.
|
||||||
|
|
||||||
|
8) Appendix D,
|
||||||
|
Revision of exit code 2 entry.
|
||||||
|
Added an example for exit code 126.
|
||||||
|
|
||||||
|
9) Fix quoting error in "Special Variables" Table in Reference Cards,
|
||||||
|
per Matthew Stanfield (Thank you!).
|
||||||
|
|
||||||
|
10) In "Complex Commands" section of "External Commands" Chapter:
|
||||||
|
Added as comment Rich's alternative awk syntax
|
||||||
|
to the month_length () example.
|
||||||
|
|
||||||
|
11) Used (with permission) code snippets from YongYe's "Tetris Game"
|
||||||
|
script in "Internal Commands" and "List Constructs" chapters.
|
||||||
|
Also added an entry for this in the "Bibliography" appendix.
|
||||||
|
The URLS for YongYe's script are:
|
||||||
|
http://bash.deta.in/Tetris_Game.sh
|
||||||
|
http://bbs.chinaunix.net/thread-3614425-1-1.html
|
||||||
|
|
||||||
|
12) In "Miscellany" chapter,
|
||||||
|
In "Shell Scripting Under Windows" section,
|
||||||
|
added reference to UNWIN, as pointed out by Greg Alheid.
|
||||||
|
|
||||||
|
13) New cover for pdf version!
|
||||||
|
|
||||||
|
14) Fixups on scripts.
|
||||||
|
[Thanks go to Darren Birkett, Chris Manson, yongye, and others.]
|
||||||
|
|
||||||
|
15) Domain shift! Changed webofcrafts.net links to deta.in.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Version 6.4, Vortexberry* release
|
Version 6.4, Vortexberry* release
|
||||||
30 August 2011
|
30 August 2011
|
||||||
|
|
||||||
|
@ -178,7 +248,7 @@ Version 6.3, Swozzleberry* release
|
||||||
14) In the "Miscellany" chapter:
|
14) In the "Miscellany" chapter:
|
||||||
Fixed the URL on Moshe Jacobson's utility (changed it to point to
|
Fixed the URL on Moshe Jacobson's utility (changed it to point to
|
||||||
the "ansi-color" script). Then, decided to rehost Jacobson's original
|
the "ansi-color" script). Then, decided to rehost Jacobson's original
|
||||||
source code on webofcrafts.net.
|
source code on webofcrafts.net (Update: deta.in).
|
||||||
(Thank you, qun-ying, for pointing out the broken URL.)
|
(Thank you, qun-ying, for pointing out the broken URL.)
|
||||||
|
|
||||||
15) In the "Variables Revisited" chapter:
|
15) In the "Variables Revisited" chapter:
|
||||||
|
@ -2512,7 +2582,8 @@ chapter:
|
||||||
Added usage example at "last" entry.
|
Added usage example at "last" entry.
|
||||||
|
|
||||||
17) In "/dev" section of "/dev and /proc" chapter:
|
17) In "/dev" section of "/dev and /proc" chapter:
|
||||||
Changed reference URL from slashdot.org to net.cn (a known spam ISP).
|
Changed reference URL from slashdot.org to news-15.net
|
||||||
|
(a known spam ISP).
|
||||||
Added to footnote about mounting a USB flash drive.
|
Added to footnote about mounting a USB flash drive.
|
||||||
|
|
||||||
18) In "Gotchas" chapter:
|
18) In "Gotchas" chapter:
|
||||||
|
@ -2725,7 +2796,7 @@ Loganberry release, 10/03/04
|
||||||
(Thanks, bojster.)
|
(Thanks, bojster.)
|
||||||
|
|
||||||
18) In "Time/Date Commands" section of "External Commands" chapter:
|
18) In "Time/Date Commands" section of "External Commands" chapter:
|
||||||
At "date" entry, dded discussion of more options.
|
At "date" entry, added discussion of more options.
|
||||||
|
|
||||||
19) In "Miscellaneous Commands" section of "External Commands" Chapter:
|
19) In "Miscellaneous Commands" section of "External Commands" Chapter:
|
||||||
Added comment to "blot-out.sh" example script noting that it may not
|
Added comment to "blot-out.sh" example script noting that it may not
|
||||||
|
|
|
@ -927,6 +927,8 @@
|
||||||
|
|
||||||
<para>* * *</para>
|
<para>* * *</para>
|
||||||
|
|
||||||
|
<para>Backlight, <link linkend="backlight">setting the
|
||||||
|
brightness</link></para>
|
||||||
<para><link linkend="backticksref">Backquotes</link>,
|
<para><link linkend="backticksref">Backquotes</link>,
|
||||||
used in <link linkend="backquotesref">command
|
used in <link linkend="backquotesref">command
|
||||||
substitution</link></para>
|
substitution</link></para>
|
||||||
|
@ -1012,12 +1014,17 @@
|
||||||
redirecting output of a a code block</para></listitem>
|
redirecting output of a a code block</para></listitem>
|
||||||
</itemizedlist></para>
|
</itemizedlist></para>
|
||||||
|
|
||||||
|
<para><link linkend="bfs">Bootable flash drives</link>, creating</para>
|
||||||
|
|
||||||
<!-- ********************** -->
|
<!-- ********************** -->
|
||||||
<para><link linkend="braceexpref">Brace expansion</link>
|
<para><link linkend="braceexpref">Brace expansion</link>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para><link
|
<listitem><para><link
|
||||||
linkend="braceexpref33">Extended</link>,
|
linkend="braceexpref33">Extended</link>,
|
||||||
<replaceable>{a..z}</replaceable></para></listitem>
|
<replaceable>{a..z}</replaceable></para></listitem>
|
||||||
|
<listitem><para><link
|
||||||
|
linkend="braceexpref3">Parameterizing</link>
|
||||||
|
</para></listitem>
|
||||||
<listitem><para>With <link
|
<listitem><para>With <link
|
||||||
linkend="braceexpref4">increment and
|
linkend="braceexpref4">increment and
|
||||||
zero-padding</link> (new feature in Bash, <link linkend="bash4ref">version
|
zero-padding</link> (new feature in Bash, <link linkend="bash4ref">version
|
||||||
|
@ -1890,7 +1897,11 @@
|
||||||
|
|
||||||
<para>* * *</para>
|
<para>* * *</para>
|
||||||
|
|
||||||
<para><link linkend="keywordref">Keywords</link></para>
|
<para><link linkend="keywordref">Keywords</link>
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem><para><link linkend="missingkeyword">error</link>,
|
||||||
|
if missing</para></listitem>
|
||||||
|
</itemizedlist></para>
|
||||||
|
|
||||||
<para><link linkend="killref">kill</link>,
|
<para><link linkend="killref">kill</link>,
|
||||||
terminate a process by <link linkend="processiddef">process ID</link>
|
terminate a process by <link linkend="processiddef">process ID</link>
|
||||||
|
@ -2573,7 +2584,7 @@
|
||||||
linkend="globbingref">globbing</link></para></listitem>
|
linkend="globbingref">globbing</link></para></listitem>
|
||||||
<listitem><para>In a
|
<listitem><para>In a
|
||||||
<link linkend="cstrinary"><firstterm>C</firstterm>-style
|
<link linkend="cstrinary"><firstterm>C</firstterm>-style
|
||||||
Trinary operator</link></para></listitem>
|
Trinary (ternary) operator</link></para></listitem>
|
||||||
</itemizedlist></para>
|
</itemizedlist></para>
|
||||||
|
|
||||||
<!-- *************************************************************** -->
|
<!-- *************************************************************** -->
|
||||||
|
@ -3393,7 +3404,7 @@
|
||||||
specifying an action upon receipt of a <link
|
specifying an action upon receipt of a <link
|
||||||
linkend="signald">signal</link></para>
|
linkend="signald">signal</link></para>
|
||||||
|
|
||||||
<para><firstterm>Trinary</firstterm> operator,
|
<para><firstterm>Trinary (ternary)</firstterm> operator,
|
||||||
<firstterm>C</firstterm>-style,
|
<firstterm>C</firstterm>-style,
|
||||||
<userinput>var>10?88:99</userinput>
|
<userinput>var>10?88:99</userinput>
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
|
|
|
@ -104,7 +104,7 @@ qky.sh
|
||||||
line 87
|
line 87
|
||||||
line 113
|
line 113
|
||||||
(The unaltered, executable script can be downloaded.
|
(The unaltered, executable script can be downloaded.
|
||||||
See: http://bash.webofcrafts.net/qky.README.html)
|
See: http://bash.deta.in/qky.README.html)
|
||||||
|
|
||||||
maned.sh
|
maned.sh
|
||||||
line 6 (comment)
|
line 6 (comment)
|
||||||
|
|
|
@ -382,6 +382,7 @@
|
||||||
<!ENTITY ipaddresses SYSTEM "ip-addresses.sh">
|
<!ENTITY ipaddresses SYSTEM "ip-addresses.sh">
|
||||||
<!ENTITY stddev SYSTEM "sd.sh">
|
<!ENTITY stddev SYSTEM "sd.sh">
|
||||||
<!ENTITY samorse SYSTEM "sam.sh">
|
<!ENTITY samorse SYSTEM "sam.sh">
|
||||||
|
<!ENTITY backlight SYSTEM "backlight.sh">
|
||||||
<!ENTITY showallc SYSTEM "show-all-colors.sh">
|
<!ENTITY showallc SYSTEM "show-all-colors.sh">
|
||||||
<!ENTITY gronsfeld SYSTEM "gronsfeld.bash">
|
<!ENTITY gronsfeld SYSTEM "gronsfeld.bash">
|
||||||
<!ENTITY gen0data SYSTEM "gen0">
|
<!ENTITY gen0data SYSTEM "gen0">
|
||||||
|
@ -407,21 +408,14 @@
|
||||||
</author>
|
</author>
|
||||||
|
|
||||||
|
|
||||||
<releaseinfo>6.4</releaseinfo>
|
<releaseinfo>6.5</releaseinfo>
|
||||||
<pubdate>30 Aug 2011</pubdate>
|
<pubdate>05 Apr 2012</pubdate>
|
||||||
<isbn>978-1-4357-5219-1</isbn>
|
<isbn>978-1-4357-5219-1</isbn>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<revhistory>
|
<revhistory>
|
||||||
|
|
||||||
<revision>
|
|
||||||
<revnumber>6.2</revnumber>
|
|
||||||
<date>17 Mar 2010</date>
|
|
||||||
<authorinitials>mc</authorinitials>
|
|
||||||
<revremark>'ROWANBERRY' release</revremark>
|
|
||||||
</revision>
|
|
||||||
|
|
||||||
<revision>
|
<revision>
|
||||||
<revnumber>6.3</revnumber>
|
<revnumber>6.3</revnumber>
|
||||||
<date>27 Apr 2011</date>
|
<date>27 Apr 2011</date>
|
||||||
|
@ -436,6 +430,13 @@
|
||||||
<revremark>'VORTEXBERRY' release</revremark>
|
<revremark>'VORTEXBERRY' release</revremark>
|
||||||
</revision>
|
</revision>
|
||||||
|
|
||||||
|
<revision>
|
||||||
|
<revnumber>6.5</revnumber>
|
||||||
|
<date>05 Apr 2012</date>
|
||||||
|
<authorinitials>mc</authorinitials>
|
||||||
|
<revremark>'TUNGSTENBERRY' release</revremark>
|
||||||
|
</revision>
|
||||||
|
|
||||||
|
|
||||||
</revhistory>
|
</revhistory>
|
||||||
|
|
||||||
|
@ -523,7 +524,7 @@
|
||||||
linkend="builtinref">builtins</link>, features internal to the
|
linkend="builtinref">builtins</link>, features internal to the
|
||||||
shell.</para></footnote>
|
shell.</para></footnote>
|
||||||
|
|
||||||
to learn. The syntax is simple and straightforward, similar to
|
to learn. The syntax is simple -- even austere -- similar to
|
||||||
that of invoking and chaining together utilities at the command
|
that of invoking and chaining together utilities at the command
|
||||||
line, and there are only a few <quote>rules</quote> governing
|
line, and there are only a few <quote>rules</quote> governing
|
||||||
their use. Most short scripts work right the first time, and
|
their use. Most short scripts work right the first time, and
|
||||||
|
@ -656,8 +657,9 @@
|
||||||
|
|
||||||
<footnote><para>An <firstterm>acronym</firstterm>
|
<footnote><para>An <firstterm>acronym</firstterm>
|
||||||
is a word formed by pasting together the initial letters of the
|
is a word formed by pasting together the initial letters of the
|
||||||
words in a tongue-tripping phrase. This is a harmful
|
words into a tongue-tripping phrase. This is a pernicious
|
||||||
and subversive practice that surely deserves severe punishment.
|
and subversive practice that surely deserves appropriately
|
||||||
|
severe punishment.
|
||||||
</para></footnote>
|
</para></footnote>
|
||||||
|
|
||||||
for <quote>Bourne-Again shell</quote> and a pun on Stephen Bourne's
|
for <quote>Bourne-Again shell</quote> and a pun on Stephen Bourne's
|
||||||
|
@ -680,7 +682,7 @@
|
||||||
|
|
||||||
<para>What follows is a tutorial on shell scripting. It relies
|
<para>What follows is a tutorial on shell scripting. It relies
|
||||||
heavily on examples to illustrate various features of the shell.
|
heavily on examples to illustrate various features of the shell.
|
||||||
The example scripts work -- they've been tested, insofar as was
|
The example scripts work -- they've been tested, insofar as
|
||||||
possible -- and some of them are even useful in real life. The
|
possible -- and some of them are even useful in real life. The
|
||||||
reader can play with the actual working code of the examples
|
reader can play with the actual working code of the examples
|
||||||
in the source archive (<filename>scriptname.sh</filename> or
|
in the source archive (<filename>scriptname.sh</filename> or
|
||||||
|
@ -690,15 +692,15 @@
|
||||||
that are Bourne shell compliant generally take a name with a
|
that are Bourne shell compliant generally take a name with a
|
||||||
<filename>.sh</filename> extension. System scripts, such as
|
<filename>.sh</filename> extension. System scripts, such as
|
||||||
those found in <filename class="directory">/etc/rc.d</filename>,
|
those found in <filename class="directory">/etc/rc.d</filename>,
|
||||||
do not conform to this nomenclature.</para></footnote>
|
do not necessarily conform to this nomenclature.</para></footnote>
|
||||||
|
|
||||||
give them <firstterm>execute</firstterm> permission
|
give them <firstterm>execute</firstterm> permission
|
||||||
(<userinput>chmod u+rx scriptname</userinput>),
|
(<userinput>chmod u+rx scriptname</userinput>),
|
||||||
then run them to see what happens. Should the <ulink
|
then run them to see what happens. Should the <ulink
|
||||||
url="http://bash.webofcrafts.net/abs-guide-latest.tar.bz2">source
|
url="http://bash.deta.in/abs-guide-latest.tar.bz2">source
|
||||||
archive</ulink> not be available, then cut-and-paste from the <ulink
|
archive</ulink> not be available, then cut-and-paste from the <ulink
|
||||||
url="http://www.tldp.org/LDP/abs/abs-guide.html.tar.gz">HTML</ulink> or
|
url="http://www.tldp.org/LDP/abs/abs-guide.html.tar.gz">HTML</ulink> or
|
||||||
<ulink url="http://bash.webofcrafts.net/abs-guide.pdf">pdf</ulink>
|
<ulink url="http://bash.deta.in/abs-guide.pdf">pdf</ulink>
|
||||||
rendered versions. Be aware that some of the scripts presented here
|
rendered versions. Be aware that some of the scripts presented here
|
||||||
introduce features before they are explained, and this may require
|
introduce features before they are explained, and this may require
|
||||||
the reader to temporarily skip ahead for enlightenment.</para>
|
the reader to temporarily skip ahead for enlightenment.</para>
|
||||||
|
@ -1788,7 +1790,11 @@ fi</programlisting>
|
||||||
<para>In a <link linkend="dblparens">double-parentheses
|
<para>In a <link linkend="dblparens">double-parentheses
|
||||||
construct</link>, the <token>?</token>
|
construct</link>, the <token>?</token>
|
||||||
can serve as an element of a C-style
|
can serve as an element of a C-style
|
||||||
<firstterm>trinary</firstterm> operator.</para>
|
<firstterm>trinary</firstterm> operator.
|
||||||
|
<footnote><para>This is more commonly known
|
||||||
|
as the <firstterm>ternary</firstterm>
|
||||||
|
operator.</para></footnote>
|
||||||
|
</para>
|
||||||
|
|
||||||
<para><varname>condition</varname><command>?</command><varname>result-if-true</varname><command>:</command><varname>result-if-false</varname></para>
|
<para><varname>condition</varname><command>?</command><varname>result-if-true</varname><command>:</command><varname>result-if-false</varname></para>
|
||||||
|
|
||||||
|
@ -2665,7 +2671,7 @@ fi</programlisting></para>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para><anchor id="piperef"></para>
|
<para><anchor id="piperef"></para>
|
||||||
<formalpara><title>pipe</title>
|
<formalpara><title>pipe</title>
|
||||||
<para>Passes the output (<filename>stdout</filename>
|
<para>Passes the output (<filename>stdout</filename>)
|
||||||
of a previous command to the input
|
of a previous command to the input
|
||||||
(<filename>stdin</filename>) of the next one, or
|
(<filename>stdin</filename>) of the next one, or
|
||||||
to the shell. This is a method of chaining commands
|
to the shell. This is a method of chaining commands
|
||||||
|
@ -6144,8 +6150,9 @@ then
|
||||||
echo "The value of \"a\" lies somewhere between 0 and 5."
|
echo "The value of \"a\" lies somewhere between 0 and 5."
|
||||||
fi</programlisting></para>
|
fi</programlisting></para>
|
||||||
|
|
||||||
<para><xref linkend="cards"> demonstrates a nested
|
<para><xref linkend="cards"> and <xref linkend="backlight">
|
||||||
<replaceable>if/then</replaceable> condition test.</para>
|
demonstrate nested <replaceable>if/then</replaceable> condition
|
||||||
|
tests.</para>
|
||||||
|
|
||||||
</sect1> <!-- Nested if/then Tests -->
|
</sect1> <!-- Nested if/then Tests -->
|
||||||
|
|
||||||
|
@ -11030,7 +11037,7 @@ case "$1" in
|
||||||
* ) FILENAME=$1;; # Otherwise, $1.
|
* ) FILENAME=$1;; # Otherwise, $1.
|
||||||
esac</programlisting></para>
|
esac</programlisting></para>
|
||||||
|
|
||||||
<para>Here is an more straightforward example of
|
<para>Here is a more straightforward example of
|
||||||
command-line parameter handling:
|
command-line parameter handling:
|
||||||
<programlisting>#! /bin/bash
|
<programlisting>#! /bin/bash
|
||||||
|
|
||||||
|
@ -11856,6 +11863,7 @@ let "z += 3" # Quotes permit the use of spaces in variable assignment.
|
||||||
<listitem><para><link linkend="mimencoderef">mimencode</link></para></listitem>
|
<listitem><para><link linkend="mimencoderef">mimencode</link></para></listitem>
|
||||||
<listitem><para><link linkend="mkbootdiskref">mkbootdisk</link></para></listitem>
|
<listitem><para><link linkend="mkbootdiskref">mkbootdisk</link></para></listitem>
|
||||||
<listitem><para><link linkend="mkdirref">mkdir</link></para></listitem>
|
<listitem><para><link linkend="mkdirref">mkdir</link></para></listitem>
|
||||||
|
<listitem><para><link linkend="mkdosfsref">mkdosfs</link></para></listitem>
|
||||||
<listitem><para><link linkend="mke2fsref">mke2fs</link></para></listitem>
|
<listitem><para><link linkend="mke2fsref">mke2fs</link></para></listitem>
|
||||||
<listitem><para><link linkend="mkfiforef">mkfifo</link></para></listitem>
|
<listitem><para><link linkend="mkfiforef">mkfifo</link></para></listitem>
|
||||||
<listitem><para><link linkend="mkisofsref">mkisofs</link></para></listitem>
|
<listitem><para><link linkend="mkisofsref">mkisofs</link></para></listitem>
|
||||||
|
@ -12043,6 +12051,7 @@ let "z += 3" # Quotes permit the use of spaces in variable assignment.
|
||||||
<listitem><para><link linkend="whoisref">whois</link></para></listitem>
|
<listitem><para><link linkend="whoisref">whois</link></para></listitem>
|
||||||
<listitem><para><link linkend="writeref">write</link></para></listitem>
|
<listitem><para><link linkend="writeref">write</link></para></listitem>
|
||||||
<listitem><para><link linkend="xargsref">xargs</link></para></listitem>
|
<listitem><para><link linkend="xargsref">xargs</link></para></listitem>
|
||||||
|
<listitem><para><link linkend="xrandrref">xrandr</link></para></listitem>
|
||||||
<listitem><para><link linkend="yaccref">yacc</link></para></listitem>
|
<listitem><para><link linkend="yaccref">yacc</link></para></listitem>
|
||||||
<listitem><para><link linkend="yesref">yes</link></para></listitem>
|
<listitem><para><link linkend="yesref">yes</link></para></listitem>
|
||||||
<listitem><para><link linkend="zcatref">zcat</link></para></listitem>
|
<listitem><para><link linkend="zcatref">zcat</link></para></listitem>
|
||||||
|
@ -12693,7 +12702,7 @@ while read f; do
|
||||||
|
|
||||||
<caution>
|
<caution>
|
||||||
<para>The <firstterm>let</firstterm> command can,
|
<para>The <firstterm>let</firstterm> command can,
|
||||||
in certain contexts, return an anomalous <link
|
in certain contexts, return a surprising <link
|
||||||
linkend="exitstatusref">exit status</link>.</para>
|
linkend="exitstatusref">exit status</link>.</para>
|
||||||
<para><programlisting># Evgeniy Ivanov points out:
|
<para><programlisting># Evgeniy Ivanov points out:
|
||||||
|
|
||||||
|
@ -12716,8 +12725,11 @@ echo $? # 0
|
||||||
let var=0
|
let var=0
|
||||||
echo $? # 1
|
echo $? # 1
|
||||||
# The command was successful, so why isn't $?=0 ???
|
# The command was successful, so why isn't $?=0 ???
|
||||||
# Anomaly!</programlisting></para>
|
|
||||||
</caution>
|
# However, as Jeff Gorak points out,
|
||||||
|
#+ this is part of the design spec for 'let' . . .
|
||||||
|
# "If the last ARG evaluates to 0, let returns 1;
|
||||||
|
# let returns 0 otherwise." ['help let']</programlisting></para></caution>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
@ -12801,6 +12813,16 @@ eval eval echo $a # d
|
||||||
<programlisting>&rot14;</programlisting>
|
<programlisting>&rot14;</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
|
<para>Here is another example of using <firstterm>eval</firstterm>
|
||||||
|
to <emphasis>evaluate</emphasis> a complex expression,
|
||||||
|
this one from YongYe's <ulink
|
||||||
|
url="http://bash.deta.in/Tetris_Game.sh">Tetris
|
||||||
|
game script</ulink>.</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<programlisting>eval ${1}+=\"${x} ${y} \"</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
<para><xref linkend="samorse"> uses
|
<para><xref linkend="samorse"> uses
|
||||||
<firstterm>eval</firstterm> to convert <link
|
<firstterm>eval</firstterm> to convert <link
|
||||||
linkend="arrayref">array</link> elements into a command
|
linkend="arrayref">array</link> elements into a command
|
||||||
|
@ -12812,6 +12834,10 @@ eval eval echo $a # d
|
||||||
<programlisting>eval var=\$$var</programlisting>
|
<programlisting>eval var=\$$var</programlisting>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<tip><para>The <firstterm>eval</firstterm> command can
|
||||||
|
be used to <link linkend="braceexpref3">parameterize
|
||||||
|
<firstterm>brace expansion</firstterm></link>.</para></tip>
|
||||||
|
|
||||||
|
|
||||||
<para><anchor id="evalrisk"></para>
|
<para><anchor id="evalrisk"></para>
|
||||||
<caution><para>The <command>eval</command> command can be
|
<caution><para>The <command>eval</command> command can be
|
||||||
|
@ -18528,7 +18554,7 @@ echo "tempfile name = $tempfile"
|
||||||
# Creates a file of that name in the current working directory
|
# Creates a file of that name in the current working directory
|
||||||
#+ with 600 file permissions.
|
#+ with 600 file permissions.
|
||||||
# A "umask 177" is therefore unnecessary,
|
# A "umask 177" is therefore unnecessary,
|
||||||
#+ but it's good programming practice anyhow.</programlisting></para>
|
#+ but it's good programming practice nevertheless.</programlisting></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
@ -18882,7 +18908,7 @@ echo "tempfile name = $tempfile"
|
||||||
script.</para>
|
script.</para>
|
||||||
<para><anchor id="ping0"></para>
|
<para><anchor id="ping0"></para>
|
||||||
|
|
||||||
<para><programlisting> HNAME=nastyspammer.com
|
<para><programlisting> HNAME=news-15.net # Notorious spammer.
|
||||||
# HNAME=$HOST # Debug: test for localhost.
|
# HNAME=$HOST # Debug: test for localhost.
|
||||||
count=2 # Send only two pings.
|
count=2 # Send only two pings.
|
||||||
|
|
||||||
|
@ -20545,6 +20571,12 @@ dd if=$filename conv=ucase > $filename.uppercase
|
||||||
<userinput>dd if=/dev/fd0 of=/home/bozo/projects/floppy.img</userinput>
|
<userinput>dd if=/dev/fd0 of=/home/bozo/projects/floppy.img</userinput>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para><anchor id="bfs">Likewise, <command>dd</command>
|
||||||
|
can create bootable flash drives.
|
||||||
|
<userinput>dd if=image.iso of=/dev/sdb</userinput>
|
||||||
|
See <ulink url="http://marlow.dk/site.php/tech/usbkeys">
|
||||||
|
Marlow's Bootable USB Keys site</ulink>.</para>
|
||||||
|
|
||||||
<para><anchor id="ddswap"></para>
|
<para><anchor id="ddswap"></para>
|
||||||
<para>
|
<para>
|
||||||
Other applications of <command>dd</command> include
|
Other applications of <command>dd</command> include
|
||||||
|
@ -23497,6 +23529,23 @@ mount -o loop /dev/loop0 /mnt # Mount it.
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><anchor id="mkdosfsref"><command>mkdosfs</command></term>
|
||||||
|
<indexterm>
|
||||||
|
<primary>mkdosfs</primary>
|
||||||
|
</indexterm>
|
||||||
|
<indexterm>
|
||||||
|
<primary>command</primary>
|
||||||
|
<secondary>mkdosfs</secondary>
|
||||||
|
</indexterm>
|
||||||
|
<listitem>
|
||||||
|
<para>Create a DOS <firstterm>FAT</firstterm>
|
||||||
|
filesystem.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><anchor id="tune2fsref"><command>tune2fs</command></term>
|
<term><anchor id="tune2fsref"><command>tune2fs</command></term>
|
||||||
<indexterm>
|
<indexterm>
|
||||||
|
@ -24453,6 +24502,28 @@ print "even when I don't know where to find Perl.\n";
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><anchor id="xrandrref"><command>xrandr</command></term>
|
||||||
|
<indexterm>
|
||||||
|
<primary>xrandr</primary>
|
||||||
|
</indexterm>
|
||||||
|
<indexterm>
|
||||||
|
<primary>command</primary>
|
||||||
|
<secondary>xrandr</secondary>
|
||||||
|
</indexterm>
|
||||||
|
<listitem>
|
||||||
|
<para>Command-line tool for manipulating the root window
|
||||||
|
of the screen.</para>
|
||||||
|
|
||||||
|
<example id="backlight">
|
||||||
|
<title><firstterm>Backlight</firstterm>: changes
|
||||||
|
the brightness of the (laptop) screen backlight</title>
|
||||||
|
<programlisting>&backlight;</programlisting>
|
||||||
|
</example>
|
||||||
|
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><anchor id="rdistref"><command>rdist</command></term>
|
<term><anchor id="rdistref"><command>rdist</command></term>
|
||||||
<indexterm>
|
<indexterm>
|
||||||
|
@ -25987,7 +26058,7 @@ done <<< $(echo ${ArrayVar[*]})
|
||||||
2>&1 | [command(s)]
|
2>&1 | [command(s)]
|
||||||
bad_command 2>&1 | awk '{print $5}' # found
|
bad_command 2>&1 | awk '{print $5}' # found
|
||||||
# Sends stderr through a pipe.
|
# Sends stderr through a pipe.
|
||||||
# |& was added to Bash 4 as an abbreviation for 2>&.
|
# |& was added to Bash 4 as an abbreviation for 2>&1 |.
|
||||||
|
|
||||||
i>&j
|
i>&j
|
||||||
# Redirects file descriptor <emphasis>i</emphasis> to <emphasis>j</emphasis>.
|
# Redirects file descriptor <emphasis>i</emphasis> to <emphasis>j</emphasis>.
|
||||||
|
@ -27366,6 +27437,12 @@ echo "$monthD" | awk '{ print $'"${1}"' }' # Tricky.
|
||||||
# Template for passing a parameter to embedded awk script:
|
# Template for passing a parameter to embedded awk script:
|
||||||
# $'"${script_parameter}"'
|
# $'"${script_parameter}"'
|
||||||
|
|
||||||
|
# Here's a slightly simpler awk construct:
|
||||||
|
# echo $monthD | awk -v month=$1 '{print $(month)}'
|
||||||
|
# Uses the -v awk option, which assigns a variable value
|
||||||
|
#+ prior to execution of the awk program block.
|
||||||
|
# Thank you, Rich.
|
||||||
|
|
||||||
# Needs error checking for correct parameter range (1-12)
|
# Needs error checking for correct parameter range (1-12)
|
||||||
#+ and for February in leap year.
|
#+ and for February in leap year.
|
||||||
}
|
}
|
||||||
|
@ -27862,6 +27939,19 @@ drwxr-xr-x 40 bozo bozo 2048 Feb 6 14:04 ..
|
||||||
<replaceable>false</replaceable> is the last one to
|
<replaceable>false</replaceable> is the last one to
|
||||||
execute).</para>
|
execute).</para>
|
||||||
|
|
||||||
|
<para>An interesting use of a two-condition <firstterm>and
|
||||||
|
list</firstterm> from YongYe's <ulink
|
||||||
|
url="http://bash.deta.in/Tetris_Game.sh">Tetris
|
||||||
|
game script</ulink>:</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<programlisting>equation()
|
||||||
|
|
||||||
|
{ # core algorithm used for doubling and halving the coordinates
|
||||||
|
[[ ${cdx} ]] && ((y=cy+(ccy-cdy)${2}2))
|
||||||
|
eval ${1}+=\"${x} ${y} \"
|
||||||
|
}</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
<example id="ex64">
|
<example id="ex64">
|
||||||
|
@ -27901,6 +27991,8 @@ drwxr-xr-x 40 bozo bozo 2048 Feb 6 14:04 ..
|
||||||
execute). This is obviously the inverse of the <quote>and
|
execute). This is obviously the inverse of the <quote>and
|
||||||
list</quote>.</para>
|
list</quote>.</para>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<example id="ex65">
|
<example id="ex65">
|
||||||
<title>Using <firstterm>or lists</firstterm> in combination
|
<title>Using <firstterm>or lists</firstterm> in combination
|
||||||
with an <firstterm>and list</firstterm></title>
|
with an <firstterm>and list</firstterm></title>
|
||||||
|
@ -31046,7 +31138,7 @@ test "$city" \< Paris && echo "Yes, Paris is greater than $city"
|
||||||
|
|
||||||
<para>Alister's <ulink url="http://code.google.com/p/ansi-color/">
|
<para>Alister's <ulink url="http://code.google.com/p/ansi-color/">
|
||||||
ansi-color</ulink> utility (based on <ulink
|
ansi-color</ulink> utility (based on <ulink
|
||||||
url="http://bash.webofcrafts.net/color-1.1.tar.gz">Moshe
|
url="http://bash.deta.in/color-1.1.tar.gz">Moshe
|
||||||
Jacobson's color utility</ulink> considerably simplifies using
|
Jacobson's color utility</ulink> considerably simplifies using
|
||||||
ANSI escape sequences. It substitutes a clean and logical
|
ANSI escape sequences. It substitutes a clean and logical
|
||||||
syntax for the clumsy constructs just discussed.</para>
|
syntax for the clumsy constructs just discussed.</para>
|
||||||
|
@ -32054,6 +32146,11 @@ echo "User entered: "$answer""</programlisting>
|
||||||
Mortice Kern Associates add shell scripting capabilities to
|
Mortice Kern Associates add shell scripting capabilities to
|
||||||
Windows.</para>
|
Windows.</para>
|
||||||
|
|
||||||
|
<para>Another alternative is <ulink
|
||||||
|
url="http://www2.research.att.com/~gsf/download/uwin/uwin.html">
|
||||||
|
UNWIN</ulink>, written by David Korn of AT&T, of <link
|
||||||
|
linkend="kornshellref">Korn Shell</link> fame.</para>
|
||||||
|
|
||||||
<para>In 2006, Microsoft released the <trademark
|
<para>In 2006, Microsoft released the <trademark
|
||||||
class=registered>Windows Powershell</trademark>,
|
class=registered>Windows Powershell</trademark>,
|
||||||
which contains limited Bash-like command-line scripting
|
which contains limited Bash-like command-line scripting
|
||||||
|
@ -32179,11 +32276,23 @@ echo {{a..c},{1..3}}
|
||||||
# a b c 1 2 3
|
# a b c 1 2 3
|
||||||
# The "comma operator" splices together strings.
|
# The "comma operator" splices together strings.
|
||||||
|
|
||||||
|
# ########## ######### ############ ########### ######### ###############
|
||||||
# Unfortunately, brace expansion does not lend itself to parameterization.
|
# Unfortunately, brace expansion does not lend itself to parameterization.
|
||||||
var1=1
|
var1=1
|
||||||
var2=5
|
var2=5
|
||||||
echo {$var1..$var2} # {1..5}</programlisting></para>
|
echo {$var1..$var2} # {1..5}
|
||||||
|
|
||||||
|
|
||||||
|
# Yet, as Emiliano G. points out, using "eval" overcomes this limitation.
|
||||||
|
|
||||||
|
start=0
|
||||||
|
end=10
|
||||||
|
for index in $(eval echo {$start..$end})
|
||||||
|
do
|
||||||
|
echo -n "$index " # 0 1 2 3 4 5 6 7 8 9 10
|
||||||
|
done
|
||||||
|
|
||||||
|
echo</programlisting></para>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
|
@ -33112,12 +33221,14 @@ echo</programlisting></para>
|
||||||
<footnote><para>Those who can, do. Those who can't . . . get an
|
<footnote><para>Those who can, do. Those who can't . . . get an
|
||||||
MCSE.</para></footnote>
|
MCSE.</para></footnote>
|
||||||
This book is somewhat of a departure from his other major work,
|
This book is somewhat of a departure from his other major work,
|
||||||
<ulink url="http://bash.webofcrafts.net/hmw60.zip">
|
<ulink url="http://bash.deta.in/hmw60.zip">
|
||||||
HOW-2 Meet Women: The Shy Man's Guide to
|
HOW-2 Meet Women: The Shy Man's Guide to
|
||||||
Relationships</ulink>. He has also written the <ulink
|
Relationships</ulink>. He has also written the <ulink
|
||||||
url="http://tldp.org/HOWTO/Software-Building-HOWTO.html">Software-Building
|
url="http://tldp.org/HOWTO/Software-Building-HOWTO.html">Software-Building
|
||||||
HOWTO</ulink>. Of late, he has been trying his (heavy) hand at
|
HOWTO</ulink>. Of late, he has been trying his
|
||||||
short fiction.</para>
|
(heavy) hand at short fiction and has at least one <ulink
|
||||||
|
url="http://www.instructables.com/id/Arduino-Morse-Code-Shield/">Instructable</ulink>
|
||||||
|
to his (dis)credit.</para>
|
||||||
|
|
||||||
<para>A Linux user since 1995 (Slackware 2.2, kernel 1.2.1),
|
<para>A Linux user since 1995 (Slackware 2.2, kernel 1.2.1),
|
||||||
the author has emitted a few
|
the author has emitted a few
|
||||||
|
@ -33130,13 +33241,13 @@ echo</programlisting></para>
|
||||||
Scrabble® adjudicator, the <ulink
|
Scrabble® adjudicator, the <ulink
|
||||||
url="http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz">yawl</ulink>
|
url="http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz">yawl</ulink>
|
||||||
word gaming list package, and the <ulink
|
word gaming list package, and the <ulink
|
||||||
url="http://bash.webofcrafts.net/qky.README.html">Quacky</ulink>
|
url="http://bash.deta.in/qky.README.html">Quacky</ulink>
|
||||||
anagramming gaming package. He got off to a rather shaky start in the
|
anagramming gaming package. He got off to a rather shaky start in the
|
||||||
computer game -- programming FORTRAN IV on a CDC 3800 (on paper coding
|
computer game -- programming FORTRAN IV on a CDC 3800 (on paper coding
|
||||||
pads, no less) -- and is not the least bit nostalgic for those
|
pads, no less) -- and is not the least bit nostalgic for those
|
||||||
days.</para>
|
days.</para>
|
||||||
|
|
||||||
<para>Living in a secluded community with wife and orange
|
<para>Living in an out-of-the-way community with wife and orange
|
||||||
tabby, he cherishes human frailty, especially his own.
|
tabby, he cherishes human frailty, especially his own.
|
||||||
<footnote><para>Sometimes it seems as if he has spent
|
<footnote><para>Sometimes it seems as if he has spent
|
||||||
his entire life flouting conventional wisdom and defying the
|
his entire life flouting conventional wisdom and defying the
|
||||||
|
@ -33578,9 +33689,6 @@ echo</programlisting></para>
|
||||||
the basic concepts of shell scripting.</para></footnote>
|
the basic concepts of shell scripting.</para></footnote>
|
||||||
In fact, this book was the <firstterm>ABS Guide</firstterm> author's
|
In fact, this book was the <firstterm>ABS Guide</firstterm> author's
|
||||||
first exposure to UNIX shell scripting, lo these many years ago.</para>
|
first exposure to UNIX shell scripting, lo these many years ago.</para>
|
||||||
<para>For more information, see <ulink
|
|
||||||
url="http://www.kochan-wood.com/">the Kochan-Wood
|
|
||||||
website</ulink>.</para>
|
|
||||||
<para>*</para>
|
<para>*</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
@ -33741,7 +33849,7 @@ echo</programlisting></para>
|
||||||
</copyright>
|
</copyright>
|
||||||
<isbn>0-691-02356-5</isbn>
|
<isbn>0-691-02356-5</isbn>
|
||||||
<abstract><para>The classic tutorial on problem-solving methods
|
<abstract><para>The classic tutorial on problem-solving methods
|
||||||
(i.e., algorithms), with special emphasis on how to teach them.</para>
|
(algorithms), with special emphasis on how to teach them.</para>
|
||||||
<para>*</para>
|
<para>*</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
@ -33806,7 +33914,7 @@ echo</programlisting></para>
|
||||||
book is part of the <firstterm>awk</firstterm> documentation,
|
book is part of the <firstterm>awk</firstterm> documentation,
|
||||||
and printed copies of the latest version are available from
|
and printed copies of the latest version are available from
|
||||||
O'Reilly and Associates.</para>
|
O'Reilly and Associates.</para>
|
||||||
<para>This book has served as an inspiration for the author
|
<para>This book served as an inspiration for the author
|
||||||
of the <firstterm>ABS Guide</firstterm>.</para>
|
of the <firstterm>ABS Guide</firstterm>.</para>
|
||||||
<para>*</para>
|
<para>*</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
|
@ -33825,9 +33933,9 @@ echo</programlisting></para>
|
||||||
</copyright>
|
</copyright>
|
||||||
<isbn>1-56592-054-6</isbn>
|
<isbn>1-56592-054-6</isbn>
|
||||||
<abstract>
|
<abstract>
|
||||||
<para>This well-written book contains some excellent pointers on shell
|
<para><anchor id="kornshellref">This well-written book contains
|
||||||
scripting in general.</para>
|
some excellent pointers on shell scripting in general.</para>
|
||||||
<para>*</para>
|
<para>*</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
|
||||||
|
@ -33887,7 +33995,7 @@ echo</programlisting></para>
|
||||||
<year>2004</year>
|
<year>2004</year>
|
||||||
</copyright>
|
</copyright>
|
||||||
<isbn>1-59327-012-7</isbn>
|
<isbn>1-59327-012-7</isbn>
|
||||||
<abstract><para>Just what the title promises . . .</para>
|
<abstract><para>Pretty much what the title promises . . .</para>
|
||||||
<para>*</para>
|
<para>*</para>
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
@ -34112,6 +34220,14 @@ url="http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-sc
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
|
||||||
|
<biblioentry>
|
||||||
|
<abstract>
|
||||||
|
<para>YongYe's wonderfully complex <ulink
|
||||||
|
url="http://bash.deta.in/Tetris_Game.sh">Tetris game
|
||||||
|
script</ulink>.</para>
|
||||||
|
</abstract>
|
||||||
|
</biblioentry>
|
||||||
|
|
||||||
<biblioentry>
|
<biblioentry>
|
||||||
<abstract>
|
<abstract>
|
||||||
<para>Mark Komarinski's <ulink
|
<para>Mark Komarinski's <ulink
|
||||||
|
@ -34228,6 +34344,15 @@ url="http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-sc
|
||||||
</abstract>
|
</abstract>
|
||||||
</biblioentry>
|
</biblioentry>
|
||||||
|
|
||||||
|
<biblioentry>
|
||||||
|
<abstract>
|
||||||
|
<para><ulink
|
||||||
|
url="http://auctiongallery.sourceforge.net">AuctionGallery</ulink>,
|
||||||
|
an application for eBay <quote>power sellers</quote> coded
|
||||||
|
in Bash.</para>
|
||||||
|
</abstract>
|
||||||
|
</biblioentry>
|
||||||
|
|
||||||
<biblioentry>
|
<biblioentry>
|
||||||
<abstract>
|
<abstract>
|
||||||
<para>Of historical interest are Colin Needham's
|
<para>Of historical interest are Colin Needham's
|
||||||
|
@ -34350,7 +34475,7 @@ url="http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-sc
|
||||||
<title>Contributed Scripts</title>
|
<title>Contributed Scripts</title>
|
||||||
|
|
||||||
<para>These scripts, while not fitting into the text of this document, do
|
<para>These scripts, while not fitting into the text of this document, do
|
||||||
illustrate some interesting shell programming techniques. They are useful,
|
illustrate some interesting shell programming techniques. Some are useful,
|
||||||
too. Have fun analyzing and running them.</para>
|
too. Have fun analyzing and running them.</para>
|
||||||
|
|
||||||
<example id="mailformat">
|
<example id="mailformat">
|
||||||
|
@ -34837,7 +34962,7 @@ url="http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-sc
|
||||||
|
|
||||||
<para><command>*</command> <emphasis>Must be quoted</emphasis>,
|
<para><command>*</command> <emphasis>Must be quoted</emphasis>,
|
||||||
otherwise it defaults to
|
otherwise it defaults to
|
||||||
<quote><varname>$@</varname></quote>.</para>
|
<varname>$@</varname>.</para>
|
||||||
|
|
||||||
|
|
||||||
<para><anchor id="bincomptab"></para>
|
<para><anchor id="bincomptab"></para>
|
||||||
|
@ -35425,7 +35550,7 @@ url="http://nixshell.wordpress.com/2011/07/13/arcade-games-written-in-a-shell-sc
|
||||||
<row>
|
<row>
|
||||||
<entry><option>(( var0 = var1<98?9:21 ))</option></entry>
|
<entry><option>(( var0 = var1<98?9:21 ))</option></entry>
|
||||||
<entry><firstterm>C-style</firstterm> <link
|
<entry><firstterm>C-style</firstterm> <link
|
||||||
linkend="cstrinary"> trinary</link> operation</entry>
|
linkend="cstrinary"> ternary</link> operation</entry>
|
||||||
</row>
|
</row>
|
||||||
<row><entry></entry><entry></entry></row>
|
<row><entry></entry><entry></entry></row>
|
||||||
<row>
|
<row>
|
||||||
|
@ -35898,13 +36023,13 @@ awk '{print $0}' $filename
|
||||||
<entry><option>2</option></entry>
|
<entry><option>2</option></entry>
|
||||||
<entry>Misuse of shell builtins (according to Bash documentation)</entry>
|
<entry>Misuse of shell builtins (according to Bash documentation)</entry>
|
||||||
<entry>empty_function() {}</entry>
|
<entry>empty_function() {}</entry>
|
||||||
<entry>Seldom seen, usually defaults to exit
|
<entry><link linkend="missingkeyword">Missing keyword</link>
|
||||||
code <errorcode>1</errorcode></entry>
|
or command</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry><option>126</option></entry>
|
<entry><option>126</option></entry>
|
||||||
<entry>Command invoked cannot execute</entry>
|
<entry>Command invoked cannot execute</entry>
|
||||||
<entry></entry>
|
<entry>/dev/null</entry>
|
||||||
<entry>Permission problem or command is not an executable</entry>
|
<entry>Permission problem or command is not an executable</entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
<row>
|
||||||
|
@ -35931,7 +36056,7 @@ awk '{print $0}' $filename
|
||||||
<row>
|
<row>
|
||||||
<entry><option>130</option></entry>
|
<entry><option>130</option></entry>
|
||||||
<entry>Script terminated by Control-C</entry>
|
<entry>Script terminated by Control-C</entry>
|
||||||
<entry></entry>
|
<entry><emphasis>Ctl-C</emphasis></entry>
|
||||||
<entry>Control-C is fatal error signal
|
<entry>Control-C is fatal error signal
|
||||||
<errorcode>2</errorcode>, (130 = 128 + 2, see above)</entry>
|
<errorcode>2</errorcode>, (130 = 128 + 2, see above)</entry>
|
||||||
</row>
|
</row>
|
||||||
|
@ -38994,6 +39119,11 @@ thegrendel@theriver.com</programlisting></para>
|
||||||
<entry>30 Aug 2011</entry>
|
<entry>30 Aug 2011</entry>
|
||||||
<entry>VORTEXBERRY release: Minor update.</entry>
|
<entry>VORTEXBERRY release: Minor update.</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><option>6.5</option></entry>
|
||||||
|
<entry>05 Apr 2012</entry>
|
||||||
|
<entry>TUNGSTENBERRY release: Minor update.</entry>
|
||||||
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table>
|
</table>
|
||||||
|
@ -39010,31 +39140,32 @@ thegrendel@theriver.com</programlisting></para>
|
||||||
<link linkend="bzipref">bzip2-ed</link>
|
<link linkend="bzipref">bzip2-ed</link>
|
||||||
<quote>tarball</quote> including both the SGML source
|
<quote>tarball</quote> including both the SGML source
|
||||||
and rendered HTML, may be downloaded from the <ulink
|
and rendered HTML, may be downloaded from the <ulink
|
||||||
url="http://bash.webofcrafts.net/abs-guide-latest.tar.bz2">author's
|
url="http://bash.deta.in/abs-guide-latest.tar.bz2">author's
|
||||||
home site</ulink>).
|
home site</ulink>).
|
||||||
|
|
||||||
A <ulink
|
A <ulink
|
||||||
url="http://bash.webofcrafts.net/abs-guide.pdf">
|
url="http://bash.deta.in/abs-guide.pdf">
|
||||||
pdf version</ulink> is also available.
|
pdf version</ulink> is also available (<ulink
|
||||||
|
url="http://www.mediafire.com/?3y6fkpd976fcash">mirror site</ulink>).
|
||||||
There is likewise an <ulink
|
There is likewise an <ulink
|
||||||
url="http://bash.webofcrafts.net/abs-guide.epub">
|
url="http://bash.deta.in/abs-guide.epub">
|
||||||
epub version</ulink>, courtesy of Craig Barnes.
|
epub version</ulink>, courtesy of Craig Barnes.
|
||||||
|
|
||||||
The <ulink
|
The <ulink
|
||||||
url="http://bash.webofcrafts.net/Change.log">change
|
url="http://bash.deta.in/Change.log">change
|
||||||
log</ulink> gives a detailed revision history.
|
log</ulink> gives a detailed revision history.
|
||||||
The <emphasis>ABS Guide</emphasis> even has <ulink
|
The <emphasis>ABS Guide</emphasis> even has <ulink
|
||||||
url="http://freshmeat.net/projects/advancedbashscriptingguide/">
|
url="http://freecode.com/projects/advancedbashscriptingguide/">
|
||||||
its own <filename>freshmeat.net</filename> page</ulink> to keep
|
its own <filename>freshmeat.net/freecode</filename> page</ulink>
|
||||||
track of major updates, user comments, and popularity ratings
|
to keep track of major updates, user comments, and popularity
|
||||||
for the project.</para>
|
ratings for the project.</para>
|
||||||
|
|
||||||
<para>The legacy hosting site for this document is the <ulink
|
<para>The legacy hosting site for this document is the <ulink
|
||||||
url="http://www.tldp.org/LDP/abs/">Linux Documentation Project</ulink>,
|
url="http://www.tldp.org/LDP/abs/">Linux Documentation Project</ulink>,
|
||||||
which maintains many other Guides and HOWTOs as well.</para>
|
which maintains many other Guides and HOWTOs as well.</para>
|
||||||
|
|
||||||
<para>Many thanks to Ronny Bangsund for donating <ulink
|
<para>Many thanks to Ronny Bangsund for donating <ulink
|
||||||
url="http://bash.webofcrafts.net/">server space</ulink> to host
|
url="http://bash.deta.in/">server space</ulink> to host
|
||||||
this project.</para>
|
this project.</para>
|
||||||
|
|
||||||
|
|
||||||
|
@ -39212,17 +39343,18 @@ distributors, or any of its associated software or documentation.</programlistin
|
||||||
url="http://gazette.linux.ru.net/rus/articles/index-abs-guide.html">Russian</ulink>,
|
url="http://gazette.linux.ru.net/rus/articles/index-abs-guide.html">Russian</ulink>,
|
||||||
<ulink url="http://premekvihan.net/bash">Czech</ulink>, <ulink
|
<ulink url="http://premekvihan.net/bash">Czech</ulink>, <ulink
|
||||||
url="http://www.linuxsir.org/bbs/showthread.php?t=256887">Chinese</ulink>,
|
url="http://www.linuxsir.org/bbs/showthread.php?t=256887">Chinese</ulink>,
|
||||||
Indonesian, Dutch, and Romanian translations are also available or
|
Indonesian, Dutch, Romanian, and Bulgarian translations are also
|
||||||
in progress. If you wish to translate this document into another
|
available or in progress. If you wish to translate this document
|
||||||
language, please feel free to do so, subject to the terms stated
|
into another language, please feel free to do so, subject to
|
||||||
above. The author wishes to be notified of such efforts.</para>
|
the terms stated above. The author wishes to be notified of such
|
||||||
|
efforts.</para>
|
||||||
|
|
||||||
<sidebar><para>For those readers who absolutely insist on making
|
<sidebar><para>For those generous readers who insist
|
||||||
a donation to the author, you may contribute a small amount
|
on making a donation to the author, you may contribute a small
|
||||||
via Paypal to my e-mail address,
|
amount via Paypal to my e-mail address,
|
||||||
<email>thegrendel.abs@gmail.com</email>. Note that this
|
<email>thegrendel.abs@gmail.com</email>. Note that this
|
||||||
is emphatically <emphasis>not</emphasis> necessary, or even
|
is <emphasis>not</emphasis> necessary.
|
||||||
recommended. This book is a free and freely distributed document
|
This book is a free and freely distributed document
|
||||||
for the use and enjoyment of the Linux community.</para></sidebar>
|
for the use and enjoyment of the Linux community.</para></sidebar>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ grep -v 'ed$' # no past tense verbs
|
||||||
# Uses "anagram" utility
|
# Uses "anagram" utility
|
||||||
#+ that is part of the author's "yawl" word list package.
|
#+ that is part of the author's "yawl" word list package.
|
||||||
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
||||||
# http://bash.webofcrafts.net/yawl-0.3.2.tar.gz
|
# http://bash.deta.in/yawl-0.3.2.tar.gz
|
||||||
|
|
||||||
exit 0 # End of code.
|
exit 0 # End of code.
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
# Uses "anagram" utility
|
# Uses "anagram" utility
|
||||||
#+ that is part of the author's "yawl" word list package.
|
#+ that is part of the author's "yawl" word list package.
|
||||||
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
||||||
# http://bash.webofcrafts.net/yawl-0.3.2.tar.gz
|
# http://bash.deta.in/yawl-0.3.2.tar.gz
|
||||||
|
|
||||||
E_NOARGS=66
|
E_NOARGS=86
|
||||||
E_BADARG=67
|
E_BADARG=87
|
||||||
MINLEN=7
|
MINLEN=7
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
|
@ -38,9 +38,9 @@ echo ${Anagrams[1]} # Second anagram.
|
||||||
|
|
||||||
# echo "${Anagrams[*]}" # To list all the anagrams in a single line . . .
|
# echo "${Anagrams[*]}" # To list all the anagrams in a single line . . .
|
||||||
|
|
||||||
# Look ahead to the "Arrays" chapter for enlightenment on
|
# Look ahead to the Arrays chapter for enlightenment on
|
||||||
#+ what's going on here.
|
#+ what's going on here.
|
||||||
|
|
||||||
# See also the agram.sh script for an example of anagram finding.
|
# See also the agram.sh script for an exercise in anagram finding.
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# backlight.sh
|
||||||
|
# reldate 02dec2011
|
||||||
|
|
||||||
|
# A bug in Fedora Core 16 messes up the keyboard backlight controls.
|
||||||
|
# This script is a quick-n-dirty workaround, essentially a shell wrapper
|
||||||
|
#+ for xrandr. It gives more control than on-screen sliders and widgets.
|
||||||
|
|
||||||
|
OUTPUT=$(xrandr | grep LV | awk '{print $1}') # Get display name!
|
||||||
|
INCR=.05 # For finer-grained control, set INCR to .03 or .02.
|
||||||
|
|
||||||
|
old_brightness=$(xrandr --verbose | grep rightness | awk '{ print $2 }')
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
bright=1 # If no command-line arg, set brightness to 1.0 (default).
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ "$1" = "+" ]
|
||||||
|
then
|
||||||
|
bright=$(echo "scale=2; $old_brightness + $INCR" | bc) # +.05
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ "$1" = "-" ]
|
||||||
|
then
|
||||||
|
bright=$(echo "scale=2; $old_brightness - $INCR" | bc) # -.05
|
||||||
|
|
||||||
|
else
|
||||||
|
if [ "$1" = "#" ] # Echoes current brightness; does not change it.
|
||||||
|
then
|
||||||
|
bright=$old_brightness
|
||||||
|
|
||||||
|
else
|
||||||
|
if [[ "$1" = "h" || "$1" = "H" ]]
|
||||||
|
then
|
||||||
|
echo
|
||||||
|
echo "Usage:"
|
||||||
|
echo "$0 [No args] Sets/resets brightness to default (1.0)."
|
||||||
|
echo "$0 + Increments brightness by 0.5."
|
||||||
|
echo "$0 - Decrements brightness by 0.5."
|
||||||
|
echo "$0 # Echoes current brightness without changing it."
|
||||||
|
echo "$0 N (number) Sets brightness to N (useful range .7 - 1.2)."
|
||||||
|
echo "$0 h [H] Echoes this help message."
|
||||||
|
echo "$0 any-other Gives xrandr usage message."
|
||||||
|
|
||||||
|
bright=$old_brightness
|
||||||
|
|
||||||
|
else
|
||||||
|
bright="$1"
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
xrandr --output "$OUTPUT" --brightness "$bright" # See xrandr manpage.
|
||||||
|
echo "Current brightness = $bright"
|
||||||
|
|
||||||
|
exit $?
|
|
@ -1,7 +1,7 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# Strips off the header from a mail/News message i.e. till the first
|
# Strips off the header from a mail/News message i.e. till the first
|
||||||
# empty line.
|
#+ empty line.
|
||||||
# Author: Mark Moraes, University of Toronto
|
# Author: Mark Moraes, University of Toronto
|
||||||
|
|
||||||
# ==> These comments added by author of this document.
|
# ==> These comments added by author of this document.
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ DICT=/usr/share/dict/word.lst
|
||||||
#+ download the author's "yawl" word list package.
|
#+ download the author's "yawl" word list package.
|
||||||
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
||||||
# or
|
# or
|
||||||
# http://bash.webofcrafts.net/yawl-0.3.2.tar.gz
|
# http://bash.deta.in/yawl-0.3.2.tar.gz
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$1" ] # If no word pattern specified
|
if [ -z "$1" ] # If no word pattern specified
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Script by Troy Engel.
|
# Script by Troy Engel.
|
||||||
# Used with permission.
|
# Used with permission.
|
||||||
|
|
||||||
TCP_HOST=www.dns-diy.com # A known spam-friendly ISP.
|
TCP_HOST=news-15.net # A known spam-friendly ISP.
|
||||||
TCP_PORT=80 # Port 80 is http.
|
TCP_PORT=80 # Port 80 is http.
|
||||||
|
|
||||||
# Try to connect. (Somewhat similar to a 'ping' . . .)
|
# Try to connect. (Somewhat similar to a 'ping' . . .)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Tip:
|
# Tip:
|
||||||
# If you're unsure of how a certain condition would evaluate,
|
# If you're unsure how a certain condition might evaluate,
|
||||||
#+ test it in an if-test.
|
#+ test it in an if-test.
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -95,7 +95,7 @@ echo
|
||||||
# When is "false" true?
|
# When is "false" true?
|
||||||
|
|
||||||
echo "Testing \"false\""
|
echo "Testing \"false\""
|
||||||
if [ "false" ] # It seems that "false" is just a string.
|
if [ "false" ] # It seems that "false" is just a string ...
|
||||||
then
|
then
|
||||||
echo "\"false\" is true." #+ and it tests true.
|
echo "\"false\" is true." #+ and it tests true.
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
filename=sys.log
|
filename=sys.log
|
||||||
|
|
||||||
cat /dev/null > $filename; echo "Creating / cleaning out file."
|
cat /dev/null > $filename; echo "Creating / cleaning out file."
|
||||||
# Creates file if it does not already exist,
|
# Creates the file if it does not already exist,
|
||||||
#+ and truncates it to zero length if it does.
|
#+ and truncates it to zero length if it does.
|
||||||
# : > filename and > filename also work.
|
# : > filename and > filename also work.
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ then
|
||||||
echo "Usage: `basename $0` filename" >&2
|
echo "Usage: `basename $0` filename" >&2
|
||||||
# Error message to stderr.
|
# Error message to stderr.
|
||||||
exit $E_NOARGS
|
exit $E_NOARGS
|
||||||
# Returns 65 as exit status of script (error code).
|
# Returns 85 as exit status of script (error code).
|
||||||
fi
|
fi
|
||||||
|
|
||||||
filename=$1
|
filename=$1
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# Name this script something like shft.sh,
|
# Name this script something like shft.sh,
|
||||||
#+ and invoke it with some parameters.
|
#+ and invoke it with some parameters.
|
||||||
#+ For example:
|
#+ For example:
|
||||||
# sh shft.sh a b c def 23 Skidoo
|
# sh shft.sh a b c def 83 barndoor
|
||||||
|
|
||||||
until [ -z "$1" ] # Until all parameters used up . . .
|
until [ -z "$1" ] # Until all parameters used up . . .
|
||||||
do
|
do
|
||||||
|
|
|
@ -68,7 +68,7 @@ fi # Doublecheck if in right directory before messing with log file.
|
||||||
|
|
||||||
|
|
||||||
tail -n $lines messages > mesg.temp # Save last section of message log file.
|
tail -n $lines messages > mesg.temp # Save last section of message log file.
|
||||||
mv mesg.temp messages # Becomes new log directory.
|
mv mesg.temp messages # Rename it as system log file.
|
||||||
|
|
||||||
|
|
||||||
# cat /dev/null > messages
|
# cat /dev/null > messages
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
a=/home/bozo/daily-journal.txt
|
address=/home/bozo/daily-journal.txt
|
||||||
|
|
||||||
echo "Basename of /home/bozo/daily-journal.txt = `basename $a`"
|
echo "Basename of /home/bozo/daily-journal.txt = `basename $address`"
|
||||||
echo "Dirname of /home/bozo/daily-journal.txt = `dirname $a`"
|
echo "Dirname of /home/bozo/daily-journal.txt = `dirname $address`"
|
||||||
echo
|
echo
|
||||||
echo "My own home is `basename ~/`." # `basename ~` also works.
|
echo "My own home is `basename ~/`." # `basename ~` also works.
|
||||||
echo "The home of my home is `dirname ~/`." # `dirname ~` also works.
|
echo "The home of my home is `dirname ~/`." # `dirname ~` also works.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
echo "This precedes the embedded Perl script within \"$0\"."
|
echo "This precedes the embedded Perl script within \"$0\"."
|
||||||
echo "==============================================================="
|
echo "==============================================================="
|
||||||
|
|
||||||
perl -e 'print "This is an embedded Perl script.\n";'
|
perl -e 'print "This line prints from an embedded Perl script.\n";'
|
||||||
# Like sed, Perl also uses the "-e" option.
|
# Like sed, Perl also uses the "-e" option.
|
||||||
|
|
||||||
echo "==============================================================="
|
echo "==============================================================="
|
||||||
|
|
|
@ -120,7 +120,7 @@ Primes=( '' $(seq $UPPER_LIMIT) )
|
||||||
i=1
|
i=1
|
||||||
until (( ( i += 1 ) > SPLIT )) # Need check only halfway.
|
until (( ( i += 1 ) > SPLIT )) # Need check only halfway.
|
||||||
do
|
do
|
||||||
if [[ -n $Primes[i] ]]
|
if [[ -n ${Primes[i]} ]]
|
||||||
then
|
then
|
||||||
t=$i
|
t=$i
|
||||||
until (( ( t += i ) > UPPER_LIMIT ))
|
until (( ( t += i ) > UPPER_LIMIT ))
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# Author: M. Cooper
|
# Author: M. Cooper
|
||||||
# License: GPL3
|
# License: GPL3
|
||||||
|
|
||||||
# ---------------------------------
|
# ----------algorithm--------------
|
||||||
# Fibo(0) = 0
|
# Fibo(0) = 0
|
||||||
# Fibo(1) = 1
|
# Fibo(1) = 1
|
||||||
# else
|
# else
|
||||||
|
|
|
@ -139,7 +139,7 @@ function Solved
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
################### MAIN () ########################
|
################### MAIN () #######################{
|
||||||
moves=0
|
moves=0
|
||||||
Jumble
|
Jumble
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ PrintPuzzle
|
||||||
echo; echo "BRAVO!"; echo
|
echo; echo "BRAVO!"; echo
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
####################################################
|
###################################################}
|
||||||
|
|
||||||
# Exercise:
|
# Exercise:
|
||||||
# --------
|
# --------
|
||||||
|
|
|
@ -38,10 +38,10 @@ echo; echo
|
||||||
|
|
||||||
LIMIT=10
|
LIMIT=10
|
||||||
|
|
||||||
for ((a=1; a <= LIMIT ; a++)) # Double parentheses, and "LIMIT" with no "$".
|
for ((a=1; a <= LIMIT ; a++)) # Double parentheses, and naked "LIMIT"
|
||||||
do
|
do
|
||||||
echo -n "$a "
|
echo -n "$a "
|
||||||
done # A construct borrowed from 'ksh93'.
|
done # A construct borrowed from ksh93.
|
||||||
|
|
||||||
echo; echo
|
echo; echo
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ echo; echo
|
||||||
# Let's use the C "comma operator" to increment two variables simultaneously.
|
# Let's use the C "comma operator" to increment two variables simultaneously.
|
||||||
|
|
||||||
for ((a=1, b=1; a <= LIMIT ; a++, b++))
|
for ((a=1, b=1; a <= LIMIT ; a++, b++))
|
||||||
do # The comma chains together operations.
|
do # The comma concatenates operations.
|
||||||
echo -n "$a-$b "
|
echo -n "$a-$b "
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# from.sh
|
# from.sh
|
||||||
|
|
||||||
# Emulates the useful "from" utility in Solaris, BSD, etc.
|
# Emulates the useful 'from' utility in Solaris, BSD, etc.
|
||||||
# Echoes the "From" header line in all messages
|
# Echoes the "From" header line in all messages
|
||||||
#+ in your e-mail directory.
|
#+ in your e-mail directory.
|
||||||
|
|
||||||
|
|
||||||
MAILDIR=~/mail/* # No quoting of variable. Why?
|
MAILDIR=~/mail/* # No quoting of variable. Why?
|
||||||
# Maybe check if exists $MAILDIR . . . if [ -d $MAILDIR ] . . .
|
# Maybe check if-exists $MAILDIR: if [ -d $MAILDIR ] . . .
|
||||||
GREP_OPTS="-H -A 5 --color" # Show file, plus extra context lines
|
GREP_OPTS="-H -A 5 --color" # Show file, plus extra context lines
|
||||||
#+ and display "From" in color.
|
#+ and display "From" in color.
|
||||||
TARGETSTR="^From" # "From" at beginning of line.
|
TARGETSTR="^From" # "From" at beginning of line.
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
func ()
|
func ()
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "$1"
|
echo "$1" # Echoes first arg passed to the function.
|
||||||
}
|
} # Does a command-line arg qualify?
|
||||||
|
|
||||||
echo "First call to function: no arg passed."
|
echo "First call to function: no arg passed."
|
||||||
echo "See if command-line arg is seen."
|
echo "See if command-line arg is seen."
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#
|
#
|
||||||
# Lines beginning with a '#' are comments, and the script ignores them.
|
# Lines beginning with a '#' are comments, and the script ignores them.
|
||||||
__.__..___
|
__.__..___
|
||||||
___._.____
|
__.._.____
|
||||||
____.___..
|
____.___..
|
||||||
_._______.
|
_._______.
|
||||||
____._____
|
____._____
|
||||||
|
|
|
@ -29,7 +29,7 @@ getopt_simple $*
|
||||||
echo "test is '$test'"
|
echo "test is '$test'"
|
||||||
echo "test2 is '$test2'"
|
echo "test2 is '$test2'"
|
||||||
|
|
||||||
exit 0 # See also, UseGetOpt.sh, a modified versio of this script.
|
exit 0 # See also, UseGetOpt.sh, a modified version of this script.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
# This is an implementation of the Gronsfeld Cipher.
|
# This is an implementation of the Gronsfeld Cipher.
|
||||||
# It's essentially a stripped-down variant of the
|
# It's essentially a stripped-down variant of the
|
||||||
#+ polyalphabetic Vigenère Tableau, but with only 10 alphabets.
|
#+ polyalphabetic Vigenère Tableau, but with only 10 alphabets.
|
||||||
# The classic Gronsfeld has a numerical sequence as the key word,
|
# The classic Gronsfeld has a numeric sequence as the key word,
|
||||||
#+ but instead we substitute a letter string, for ease of use.
|
#+ but here we substitute a letter string, for ease of use.
|
||||||
# Allegedly, this cipher was invented by the eponymous Count Gronsfeld
|
# Allegedly, this cipher was invented by the eponymous Count Gronsfeld
|
||||||
#+ in the 17th Century. It was at one time considered to be unbreakable.
|
#+ in the 17th Century. It was at one time considered to be unbreakable.
|
||||||
# Note that this is ###not### a secure cipher by modern standards.
|
# Note that this is ###not### a secure cipher by modern standards.
|
||||||
|
|
||||||
# Global Variables #
|
# Global Variables #
|
||||||
Enc_suffix="29378" # Encrypted text output with this 5-digit suffix.
|
Enc_suffix="29379" # Encrypted text output with this 5-digit suffix.
|
||||||
# This functions as a decryption flag,
|
# This functions as a decryption flag,
|
||||||
#+ and when used to generate passwords adds security.
|
#+ and when used to generate passwords adds security.
|
||||||
Default_key="gronsfeldk"
|
Default_key="gronsfeldk"
|
||||||
|
@ -31,7 +31,7 @@ wraplen=26 # Wrap around if past end of alphabet.
|
||||||
dflag= # Decrypt flag (set if $Enc_suffix present).
|
dflag= # Decrypt flag (set if $Enc_suffix present).
|
||||||
E_NOARGS=76 # Missing command-line args?
|
E_NOARGS=76 # Missing command-line args?
|
||||||
DEBUG=77 # Debugging flag.
|
DEBUG=77 # Debugging flag.
|
||||||
declare -a offsets # This array holds the numerical shift values for
|
declare -a offsets # This array holds the numeric shift values for
|
||||||
#+ encryption/decryption.
|
#+ encryption/decryption.
|
||||||
|
|
||||||
########Keychain#########
|
########Keychain#########
|
||||||
|
@ -64,10 +64,10 @@ do
|
||||||
# Shift forward to encrypt.
|
# Shift forward to encrypt.
|
||||||
test $(( $idx % $GROUPLEN)) = 0 && echo -n " " # Groups of 5 letters.
|
test $(( $idx % $GROUPLEN)) = 0 && echo -n " " # Groups of 5 letters.
|
||||||
# Comment out above line for output as a string without whitespace,
|
# Comment out above line for output as a string without whitespace,
|
||||||
# for example, if using the script as a password generator.
|
#+ for example, if using the script as a password generator.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
((off1--)) # Normalize.
|
((off1--)) # Normalize. Why is this necessary?
|
||||||
|
|
||||||
if [ $off1 -lt 0 ]
|
if [ $off1 -lt 0 ]
|
||||||
then # Catch negative indices.
|
then # Catch negative indices.
|
||||||
|
@ -93,7 +93,7 @@ done
|
||||||
|
|
||||||
# int main () {
|
# int main () {
|
||||||
|
|
||||||
# Check if command-line args.
|
# Check for command-line args.
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
then
|
then
|
||||||
echo "Usage: $0 TEXT TO ENCODE/DECODE"
|
echo "Usage: $0 TEXT TO ENCODE/DECODE"
|
||||||
|
@ -140,8 +140,8 @@ exit $? # } End-of-script
|
||||||
# This script can function as a password generator,
|
# This script can function as a password generator,
|
||||||
#+ with several minor mods, see above.
|
#+ with several minor mods, see above.
|
||||||
# That would allow an easy-to-remember password, even the word
|
# That would allow an easy-to-remember password, even the word
|
||||||
#+ "password" itself, which encrypts to vrgfotvo29378
|
#+ "password" itself, which encrypts to vrgfotvo29379
|
||||||
#+ a fairly secure password not susceptible to a dictionary attack.
|
#+ a fairly secure password not susceptible to a dictionary attack.
|
||||||
# Or, you could use your own name (surely that's easy to remember!).
|
# Or, you could use your own name (surely that's easy to remember!).
|
||||||
# For example, Bozo Bozeman encrypts to hfnbttdppkt29378.
|
# For example, Bozo Bozeman encrypts to hfnbttdppkt29379.
|
||||||
# ************************************************************** #
|
# ************************************************************** #
|
||||||
|
|
|
@ -102,7 +102,7 @@ Optional environment variables
|
||||||
Additional documentation
|
Additional documentation
|
||||||
Download the archived set of scripts
|
Download the archived set of scripts
|
||||||
explaining and illustrating the function contained within this script.
|
explaining and illustrating the function contained within this script.
|
||||||
http://bash.webofcrafts.net/mszick_clf.tar.bz2
|
http://bash.deta.in/mszick_clf.tar.bz2
|
||||||
|
|
||||||
|
|
||||||
Study notes
|
Study notes
|
||||||
|
|
|
@ -3,12 +3,16 @@
|
||||||
|
|
||||||
file=words.data # Data file from which to read words to test.
|
file=words.data # Data file from which to read words to test.
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Testing file $file"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
while [ "$word" != end ] # Last word in data file.
|
while [ "$word" != end ] # Last word in data file.
|
||||||
do # ^^^
|
do # ^^^
|
||||||
read word # From data file, because of redirection at end of loop.
|
read word # From data file, because of redirection at end of loop.
|
||||||
look $word > /dev/null # Don't want to display lines in dictionary file.
|
look $word > /dev/null # Don't want to display lines in dictionary file.
|
||||||
|
# Searches for words in the file /usr/share/dict/words
|
||||||
|
#+ (usually a link to linux.words).
|
||||||
lookup=$? # Exit status of 'look' command.
|
lookup=$? # Exit status of 'look' command.
|
||||||
|
|
||||||
if [ "$lookup" -eq 0 ]
|
if [ "$lookup" -eq 0 ]
|
||||||
|
|
|
@ -7,3 +7,7 @@ do
|
||||||
# done # Required keyword 'done' commented out in line 7.
|
# done # Required keyword 'done' commented out in line 7.
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
# === #
|
||||||
|
|
||||||
|
echo $? # 2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# May need to be invoked with #!/bin/bash2 on older machines.
|
#
|
||||||
#
|
#
|
||||||
# Random password generator for Bash 2.x +
|
# Random password generator for Bash 2.x +
|
||||||
#+ by Antek Sawicki <tenox@tenox.tc>,
|
#+ by Antek Sawicki <tenox@tenox.tc>,
|
||||||
|
|
|
@ -13,7 +13,7 @@ WLIST=/usr/share/dict/word.lst
|
||||||
# ^^^^^^^^ Word list file found here.
|
# ^^^^^^^^ Word list file found here.
|
||||||
# ASCII word list, one word per line, UNIX format.
|
# ASCII word list, one word per line, UNIX format.
|
||||||
# A suggested list is the script author's "yawl" word list package.
|
# A suggested list is the script author's "yawl" word list package.
|
||||||
# http://bash.webofcrafts.net/yawl-0.3.2.tar.gz
|
# http://bash.deta.in/yawl-0.3.2.tar.gz
|
||||||
# or
|
# or
|
||||||
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
# http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ E_DUP=70 # Duplicate word error.
|
||||||
TIMEOUT=10 # Time for word input.
|
TIMEOUT=10 # Time for word input.
|
||||||
|
|
||||||
NVLET=10 # 10 letters for non-vulnerable.
|
NVLET=10 # 10 letters for non-vulnerable.
|
||||||
VULET=13 # 13 letters for vulnerable (not yet implemented).
|
VULET=13 # 13 letters for vulnerable (not yet implemented!).
|
||||||
|
|
||||||
declare -a Words
|
declare -a Words
|
||||||
declare -a Status
|
declare -a Status
|
||||||
|
@ -70,7 +70,7 @@ but it is otherwise feature-complete.
|
||||||
|
|
||||||
As the game begins, the player gets 10 letters.
|
As the game begins, the player gets 10 letters.
|
||||||
The object is to construct valid dictionary words
|
The object is to construct valid dictionary words
|
||||||
of at least 3-letter-length from the letterset.
|
of at least 3-letter length from the letterset.
|
||||||
Each word-length category
|
Each word-length category
|
||||||
-- 3-letter, 4-letter, 5-letter, ... --
|
-- 3-letter, 4-letter, 5-letter, ... --
|
||||||
fills up with the fifth word entered,
|
fills up with the fifth word entered,
|
||||||
|
@ -103,7 +103,7 @@ Category completion bonuses are:
|
||||||
6-letter words 800
|
6-letter words 800
|
||||||
7-letter words 2000
|
7-letter words 2000
|
||||||
8-letter words 10000
|
8-letter words 10000
|
||||||
This is a simplification of the absurdly complicated Perquackey bonus
|
This is a simplification of the absurdly baroque Perquackey bonus
|
||||||
scoring system.
|
scoring system.
|
||||||
|
|
||||||
INSTRUCTION2
|
INSTRUCTION2
|
||||||
|
@ -117,7 +117,7 @@ Hitting just ENTER for a word entry ends the game.
|
||||||
|
|
||||||
Individual word entry is timed to a maximum of 10 seconds.
|
Individual word entry is timed to a maximum of 10 seconds.
|
||||||
*** Timing out on an entry ends the game. ***
|
*** Timing out on an entry ends the game. ***
|
||||||
Other than that, the game is untimed.
|
Aside from that, the game is untimed.
|
||||||
|
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
Game statistics are automatically saved to a file.
|
Game statistics are automatically saved to a file.
|
||||||
|
@ -277,7 +277,7 @@ get_word ()
|
||||||
}
|
}
|
||||||
|
|
||||||
is_constructable ()
|
is_constructable ()
|
||||||
{ # This was the most complex and difficult-to-write function.
|
{ # This is the most complex and difficult-to-write function.
|
||||||
local -a local_LS=( "${LS[@]}" ) # Local copy of letter set.
|
local -a local_LS=( "${LS[@]}" ) # Local copy of letter set.
|
||||||
local is_found=0
|
local is_found=0
|
||||||
local idx=0
|
local idx=0
|
||||||
|
@ -305,7 +305,7 @@ is_constructable ()
|
||||||
|
|
||||||
is_valid ()
|
is_valid ()
|
||||||
{ # Surprisingly easy to check if word in dictionary ...
|
{ # Surprisingly easy to check if word in dictionary ...
|
||||||
fgrep -qw "$1" "$WLIST" # ... thanks to 'grep' ...
|
fgrep -qw "$1" "$WLIST" # ... courtesy of 'grep' ...
|
||||||
echo $?
|
echo $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ check_word ()
|
||||||
return $NG
|
return $NG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
### FIXME: Streamline the above code.
|
### FIXME: Streamline the above code block.
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,7 +394,7 @@ play ()
|
||||||
{
|
{
|
||||||
word="Start game" # Dummy word, to start ...
|
word="Start game" # Dummy word, to start ...
|
||||||
|
|
||||||
while [ "$word" ] # If player just hits return (blank word),
|
while [ "$word" ] # If player just hits return (null word),
|
||||||
do #+ then game ends.
|
do #+ then game ends.
|
||||||
echo "$word: "${Status[@]}""
|
echo "$word: "${Status[@]}""
|
||||||
echo -n "Last score: [${Score[0]}] TOTAL score: [${Score[1]}]: Next word: "
|
echo -n "Last score: [${Score[0]}] TOTAL score: [${Score[1]}]: Next word: "
|
||||||
|
@ -414,7 +414,7 @@ play ()
|
||||||
done # Exit game.
|
done # Exit game.
|
||||||
|
|
||||||
### FIXME: The play () function calls too many other functions.
|
### FIXME: The play () function calls too many other functions.
|
||||||
### This is perilously close to "spaghetti code" ...
|
### This verges on "spaghetti code" !!!
|
||||||
}
|
}
|
||||||
|
|
||||||
end_of_game ()
|
end_of_game ()
|
||||||
|
@ -457,9 +457,10 @@ exit $?
|
||||||
# 3) Improve the time-out ... maybe change to untimed entry,
|
# 3) Improve the time-out ... maybe change to untimed entry,
|
||||||
#+ but with a time limit for the overall round.
|
#+ but with a time limit for the overall round.
|
||||||
# 4) An on-screen countdown timer would be nice.
|
# 4) An on-screen countdown timer would be nice.
|
||||||
# 5) Implement "vulnerable" mode of play.
|
# 5) Implement "vulnerable" mode of play for compatibility with classic
|
||||||
|
#+ version of the game.
|
||||||
# 6) Improve save-to-file capability (and maybe make it optional).
|
# 6) Improve save-to-file capability (and maybe make it optional).
|
||||||
# 7) Fix bugs!!!
|
# 7) Fix bugs!!!
|
||||||
|
|
||||||
# Reference for more info:
|
# For more info, reference:
|
||||||
# http://bash.webofcrafts.net/qky.README.html
|
# http://bash.deta.in/qky.README.html
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
# A "ramdisk" is a segment of system RAM memory
|
# A "ramdisk" is a segment of system RAM memory
|
||||||
#+ which acts as if it were a filesystem.
|
#+ which acts as if it were a filesystem.
|
||||||
# Its advantage is very fast access (read/write time).
|
# Its advantage is very fast access (read/write time).
|
||||||
# Disadvantages: volatility, loss of data on reboot or powerdown.
|
# Disadvantages: volatility, loss of data on reboot or powerdown,
|
||||||
#+ less RAM available to system.
|
#+ less RAM available to system.
|
||||||
#
|
#
|
||||||
# Of what use is a ramdisk?
|
# Of what use is a ramdisk?
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
E_NON_ROOT_USER=70 # Must run as root.
|
E_NON_ROOT_USER=70 # Must run as root.
|
||||||
ROOTUSER_NAME=root
|
ROOTUSER_NAME=root
|
||||||
|
|
||||||
MOUNTPT=/mnt/ramdisk
|
MOUNTPT=/mnt/ramdisk # Create with mkdir /mnt/ramdisk.
|
||||||
SIZE=2000 # 2K blocks (change as appropriate)
|
SIZE=2000 # 2K blocks (change as appropriate)
|
||||||
BLOCKSIZE=1024 # 1K (1024 byte) block size
|
BLOCKSIZE=1024 # 1K (1024 byte) block size
|
||||||
DEVICE=/dev/ram0 # First ram device
|
DEVICE=/dev/ram0 # First ram device
|
||||||
|
|
|
@ -13,7 +13,8 @@ POS=2 # Starting from position 2 in the string.
|
||||||
LEN=8 # Extract eight characters.
|
LEN=8 # Extract eight characters.
|
||||||
|
|
||||||
str1=$( echo "$str0" | md5sum | md5sum )
|
str1=$( echo "$str0" | md5sum | md5sum )
|
||||||
# Doubly scramble: ^^^^^^ ^^^^^^
|
# Doubly scramble ^^^^^^ ^^^^^^
|
||||||
|
#+ by piping and repiping to md5sum.
|
||||||
|
|
||||||
randstring="${str1:$POS:$LEN}"
|
randstring="${str1:$POS:$LEN}"
|
||||||
# Can parameterize ^^^^ ^^^^
|
# Can parameterize ^^^^ ^^^^
|
||||||
|
|
|
@ -5,7 +5,7 @@ RANDOM=$$ # Reseed the random number generator using script process ID.
|
||||||
|
|
||||||
PIPS=6 # A die has 6 pips.
|
PIPS=6 # A die has 6 pips.
|
||||||
MAXTHROWS=600 # Increase this if you have nothing better to do with your time.
|
MAXTHROWS=600 # Increase this if you have nothing better to do with your time.
|
||||||
throw=0 # Throw count.
|
throw=0 # Number of times the dice have been cast.
|
||||||
|
|
||||||
ones=0 # Must initialize counts to zero,
|
ones=0 # Must initialize counts to zero,
|
||||||
twos=0 #+ since an uninitialized variable is null, not zero.
|
twos=0 #+ since an uninitialized variable is null, not zero.
|
||||||
|
@ -30,8 +30,8 @@ update_count()
|
||||||
{
|
{
|
||||||
case "$1" in
|
case "$1" in
|
||||||
0) let "ones += 1";; # Since die has no "zero", this corresponds to 1.
|
0) let "ones += 1";; # Since die has no "zero", this corresponds to 1.
|
||||||
1) let "twos += 1";; # And this to 2, etc.
|
1) let "twos += 1";; # And this to 2.
|
||||||
2) let "threes += 1";;
|
2) let "threes += 1";; # Etc.
|
||||||
3) let "fours += 1";;
|
3) let "fours += 1";;
|
||||||
4) let "fives += 1";;
|
4) let "fives += 1";;
|
||||||
5) let "sixes += 1";;
|
5) let "sixes += 1";;
|
||||||
|
@ -65,4 +65,4 @@ exit 0
|
||||||
# Exercise (easy):
|
# Exercise (easy):
|
||||||
# ---------------
|
# ---------------
|
||||||
# Rewrite this script to flip a coin 1000 times.
|
# Rewrite this script to flip a coin 1000 times.
|
||||||
# Choices are "HEADS" and "TAILS".
|
# Choices are "HEADS" and "TAILS."
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# rot13.sh: Classic rot13 algorithm,
|
# rot13.sh: Classic rot13 algorithm,
|
||||||
# encryption that might fool a 3-year old.
|
# encryption that might fool a 3-year old
|
||||||
|
# for about 10 minutes.
|
||||||
|
|
||||||
# Usage: ./rot13.sh filename
|
# Usage: ./rot13.sh filename
|
||||||
# or ./rot13.sh <filename
|
# or ./rot13.sh <filename
|
||||||
# or ./rot13.sh and supply keyboard input (stdin)
|
# or ./rot13.sh and supply keyboard input (stdin)
|
||||||
|
|
||||||
cat "$@" | tr 'a-zA-Z' 'n-za-mN-ZA-M' # "a" goes to "n", "b" to "o", etc.
|
cat "$@" | tr 'a-zA-Z' 'n-za-mN-ZA-M' # "a" goes to "n", "b" to "o" ...
|
||||||
# The 'cat "$@"' construction
|
# The cat "$@" construct
|
||||||
#+ permits getting input either from stdin or from files.
|
#+ permits input either from stdin or from files.
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# sam.sh, v. 01
|
# sam.sh, v. .01a
|
||||||
# Still Another Morse (code training script)
|
# Still Another Morse (code training script)
|
||||||
# With apologies to Sam (F.B.) Morse.
|
# With profuse apologies to Sam (F.B.) Morse.
|
||||||
# Author: Mendel Cooper
|
# Author: Mendel Cooper
|
||||||
# License: GPL3
|
# License: GPL3
|
||||||
# Reldate: 05/25/11
|
# Reldate: 05/25/11
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
# Get the wav files from the source tarball:
|
# Get the wav files from the source tarball:
|
||||||
# http://bash.webofcrafts.net/abs-guide-latest.tar.bz2
|
# http://bash.deta.in/abs-guide-latest.tar.bz2
|
||||||
DOT='soundfiles/dot.wav'
|
DOT='soundfiles/dot.wav'
|
||||||
DASH='soundfiles/dash.wav'
|
DASH='soundfiles/dash.wav'
|
||||||
# Maybe move soundfiles to /usr/local/sounds?
|
# Maybe move soundfiles to /usr/local/sounds?
|
||||||
|
@ -64,7 +64,7 @@ morse[5]="dot; dot; dot; dot; dot"
|
||||||
morse[6]="dash; dot; dot; dot; dot"
|
morse[6]="dash; dot; dot; dot; dot"
|
||||||
morse[7]="dash; dash; dot; dot; dot"
|
morse[7]="dash; dash; dot; dot; dot"
|
||||||
morse[8]="dash; dash; dash; dot; dot"
|
morse[8]="dash; dash; dash; dot; dot"
|
||||||
morse[8]="dash; dash; dash; dash; dot"
|
morse[9]="dash; dash; dash; dash; dot"
|
||||||
# The following must be escaped or quoted.
|
# The following must be escaped or quoted.
|
||||||
morse[?]="dot; dot; dash; dash; dot; dot"
|
morse[?]="dot; dot; dash; dash; dot; dot"
|
||||||
morse[.]="dot; dash; dot; dash; dot; dash"
|
morse[.]="dot; dash; dot; dash; dot; dash"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
# Check for command-line arg.
|
# Check for command-line arg.
|
||||||
ARGCOUNT=1
|
ARGCOUNT=1
|
||||||
E_WRONGARGS=65
|
E_WRONGARGS=85
|
||||||
if [ $# -ne "$ARGCOUNT" ]
|
if [ $# -ne "$ARGCOUNT" ]
|
||||||
then
|
then
|
||||||
echo "Usage: `basename $0` domain-name"
|
echo "Usage: `basename $0` domain-name"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# t-out.sh
|
# t-out.sh [time-out]
|
||||||
# Inspired by a suggestion from "syngin seven" (thanks).
|
# Inspired by a suggestion from "syngin seven" (thanks).
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ TIMELIMIT=4 # 4 seconds
|
||||||
read -t $TIMELIMIT variable <&1
|
read -t $TIMELIMIT variable <&1
|
||||||
# ^^^
|
# ^^^
|
||||||
# In this instance, "<&1" is needed for Bash 1.x and 2.x,
|
# In this instance, "<&1" is needed for Bash 1.x and 2.x,
|
||||||
# but unnecessary for Bash 3.x.
|
# but unnecessary for Bash 3+.
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ then
|
||||||
exit $E_BADARGS
|
exit $E_BADARGS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "$1" ] # Check if file exists.
|
if [ ! -f "$1" ] # Does file exist?
|
||||||
then
|
then
|
||||||
echo "File \"$1\" does not exist."
|
echo "File \"$1\" does not exist."
|
||||||
exit $E_NOFILE
|
exit $E_NOFILE
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
E_WRONG_DIRECTORY=65
|
E_WRONG_DIRECTORY=85
|
||||||
|
|
||||||
clear # Clear the screen.
|
clear # Clear the screen.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ syzygy
|
||||||
orangutan
|
orangutan
|
||||||
doing
|
doing
|
||||||
madeupword
|
madeupword
|
||||||
making
|
gargantuan
|
||||||
|
linux
|
||||||
|
nicrosoft
|
||||||
nogood
|
nogood
|
||||||
ziggurat
|
ziggurat
|
||||||
what
|
what
|
||||||
|
|
|
@ -21,7 +21,7 @@ while read i
|
||||||
do
|
do
|
||||||
echo $i
|
echo $i
|
||||||
global=3D": Available outside the loop."
|
global=3D": Available outside the loop."
|
||||||
# ... because it does *not* run in a subshell.
|
# ... because it does NOT run in a subshell.
|
||||||
done < <( echo "random input" )
|
done < <( echo "random input" )
|
||||||
# ^ ^
|
# ^ ^
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ while read line
|
||||||
do
|
do
|
||||||
outloop[$index]="$line"
|
outloop[$index]="$line"
|
||||||
((index++))
|
((index++))
|
||||||
# It does *not* run in a subshell, so ...
|
# It does NOT run in a subshell, so ...
|
||||||
done < <( cat $0 )
|
done < <( cat $0 )
|
||||||
echo "OUTPUT = "
|
echo "OUTPUT = "
|
||||||
echo ${outloop[*]} # ... the entire script echoes.
|
echo ${outloop[*]} # ... the entire script echoes.
|
||||||
|
|
|
@ -31,7 +31,7 @@ WORDFILE=/usr/share/dict/linux.words # Dictionary file.
|
||||||
# May specify a different word list file
|
# May specify a different word list file
|
||||||
#+ of one-word-per-line format.
|
#+ of one-word-per-line format.
|
||||||
# For example, the "yawl" word-list package,
|
# For example, the "yawl" word-list package,
|
||||||
# http://bash.webofcrafts.net/yawl-0.3.2.tar.gz
|
# http://bash.deta.in/yawl-0.3.2.tar.gz
|
||||||
|
|
||||||
|
|
||||||
wlist=`strings "$1" | tr A-Z a-z | tr '[:space:]' Z | \
|
wlist=`strings "$1" | tr A-Z a-z | tr '[:space:]' Z | \
|
||||||
|
|
Loading…
Reference in New Issue