procmail
[Top] [All Lists]

Re: tail and procmail

2009-11-16 01:11:44
On Sun, 2009-11-15 at 21:43 -0800, Bart Schaefer wrote:

On Sun, Nov 15, 2009 at 6:04 PM, JW Simpson <john(_at_)swajime(_dot_)com> 
wrote:
VAR1=`ls -l`
VAR2=`tail -1 <<< "$VAR1"`

That might work for versions of bash/ksh/zsh released in the last 3
years or so.  If you happen to have something older, you need

Hmm ... my newbieness shows?
This doc is dated 2002 ->
http://ccrma.stanford.edu/planetccrma/man/man1/bash.1.html
I think though, now that you mention it, that it is standard practice to
set SHELL = /bin/sh ?


VAR2=`echo "$VAR1" | tail -1`

The double-quotes should assure that the newlines in the value of
$VAR1 are preserved (JW's answer relies upon that as well).

Oh, and make sure LINEBUF is set large enough to contain the entire
output of "ls -l" or you'll get very unexpected results.
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail

-- 
JW Simpson <john(_at_)swajime(_dot_)com>
SwaJime's Cove℠
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail
<Prev in Thread] Current Thread [Next in Thread>