[Smaug] A quick scripting puzzle
Thomas Leavitt
thomas at thomasleavitt.org
Sat Nov 19 12:40:07 PST 2005
On Sat, 2005-11-19 at 08:07 -0800, smaug-request at lists.svlug.org wrote:
> Message: 5
> Date: Fri, 18 Nov 2005 18:04:11 -0800
> From: Dash McElroy <dmcelroy at bayfed.com>
> Subject: Re: [Smaug] A quick scripting puzzle
> To: smaug at lists.svlug.org
> Message-ID: <487D5538-C27D-433C-A92C-56507FED99A4 at bayfed.com>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> LASTSUNDAY=`cal|colrm 3|tail -c4`
>
> -Dash
>
colrm is on my system
Definitely neat.
However, this produces two lines of output (last line is blank), which
requires more processing before the variable can be used, right?
Hmm... nope, guess the second line is silently dropped during the
assignment. Hmm... actually, it seems that any whitespace at all is
dropped in the assignment, as "cal 4 2006 | colrm 3 | tail -c4" puts the
numerical date on the second line, instead of the first, but it still
winds up being assigned properly.
I'm not a shell scripting expert, so this is all new to me. Mind
stimulating exercise.
Thomas
More information about the Smaug
mailing list