[lug] Stripping whitespace in a shell script

Riggs, Rob RRiggs at doubleclick.net
Wed Feb 20 10:04:46 MST 2002


Thanks Chip. But that sed script will only strip spaces. I'm looking to
strip all whitespace, not just " ", but also newlines, tabs, etc.

-----Original Message-----
From: Chip Atkinson [mailto:chip at rmpg.org]
Sent: Wednesday, February 20, 2002 9:55 AM
To: 'lug at lug.boulder.co.us'
Subject: Re: [lug] Stripping whitespace in a shell script


You could use sed.  For example,
sed -e "s/  *$//"
This works in the test that I just ran.

Chip

On Wed, 20 Feb 2002, Riggs, Rob wrote:

> I'm looking for an effecient way to strip whitespace from the trailing end
> of a line of text in a shell script.
>
> I was using "awk '{print $1}'", but it breaks down when there is embedded
> whitespace in the text, spitting out only the portion prior to the first
> embedded whitespace. While whitespace should not be embedded, it occurs
> frequently enough that I need to deal with it.
>
> Any suggestions on how to do it in Bash script?
>
> -Rob
>
>
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
>

_______________________________________________
Web Page:  http://lug.boulder.co.us
Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug



More information about the LUG mailing list