Unix Shell - Re: strip off trailing+leading blanks

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > September 2006 > Re: strip off trailing+leading blanks





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: strip off trailing+leading blanks
Lasse Kliemann

2006-09-21, 1:25 pm

Michael Paoli <michael1cat@yahoo.com> wrote:
> Lasse Kliemann wrote:
>
> $ var=' foo bar baz '
> $ echo X"$var"X
> X foo bar baz X
> $ read var << __EOT__
> $ echo X"$var"X
> Xfoo bar bazX
> $
>
> Also note that expr is also built-in to many shells.


Looks like we've got it :-)

Since I usually use http://code.dogmap.org/prjlibs/ , which has

prj_heredoc() {
{ : "${2?}" &&
shift &&
"$@"
} <<EOT
$1
EOT
}

this is just one line for me:

prj_heredoc "$var" read var


Thank you all.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com