[Gllug] Stripping whitespace in bash script

Dylan dylan at dylan.me.uk
Sat Aug 12 00:03:35 UTC 2006


On Saturday 12 August 2006 00:41, Alex Sayle wrote:
> main example, which uses sed to remove all (zero or more) spaces
> at the end of the line and the uses the example above to put
> brackets around the string.
>
> $echo "word   " | sed -e 's/ *$//g' | sed -e 's/\(.*\)/[\1]/'
> [word]
>
> details in man pages sed(1), and there's always funny looking awk(1)
> and perl ( perldoc -f chomp ) that do the job just fine.

That's got it, thanks!
Dylan
-- 
"The man who strikes first admits that his ideas have given out."
                                                (Chinese Proverb)
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list