Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Warren Block
On Fri, 12 May 2006, Giorgos Keramidas wrote: The first sed expression is missing "//". Correcting that: sed -i -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' test.txt sed: lstat: No such file or directory Yeah, I noticed the missing // in the first regexp, but only after I had posted the

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Giorgos Keramidas
On 2006-05-12 10:41, Warren Block <[EMAIL PROTECTED]> wrote: >On Fri, 12 May 2006, Giorgos Keramidas wrote: >> There are at least the following ways: >> >>sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... >>perl -pi -e 's/^\s*(\S.*\S)[ \t]*$/$1/' file ... >> >> The first one seems

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Giorgos Keramidas
On 2006-05-12 17:56, "[EMAIL PROTECTED]@mgEDV.net" <[EMAIL PROTECTED]> wrote: >>> sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... > > why not use just (you can change the "-" separator to "/" as above): > sed -e 's-^ *--g' -e 's- *$--g' Because this provides no additional help with

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Kyrre Nygard
At 16:50 12.05.2006, Martin McCormick wrote: This looks like something sed should be able to do, but I haven't had any luck at all. I wanted to remove any whitespace that has accidentally gotten added to the beginning or end of some lines of text. I made a test file that looks like: le

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Warren Block
On Fri, 12 May 2006, Giorgos Keramidas wrote: There are at least the following ways: sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... perl -pi -e 's/^\s*(\S.*\S)[ \t]*$/$1/' file ... The first one seems more straightforward to me most of the time, but there are times

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Chuck Swiger
Giorgos Keramidas wrote: On 2006-05-12 11:27, Chuck Swiger <[EMAIL PROTECTED]> wrote: It is, and I wish to acknowledge the above are entirely valid solutions to the problem, but... python -c 'import sys; print sys.stdin.read().strip()' < file... ...has the advantage of being human readabl

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Martin McCormick
Chuck Swiger quotes and writes: >Giorgos Keramidas wrote: >> This fails to remove multiple occurences of the [[:space:]] class. >> >> There are at least the following ways: >> >> sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... That did it! As soon as I saw the *, I knew w

RE: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread [EMAIL PROTECTED]@mgEDV.net
> > sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... why not use just (you can change the "-" separator to "/" as above): sed -e 's-^ *--g' -e 's- *$--g' usage examples: -> cat file| sed ... >file1 -> echo $variable| sed ... |grep xy -> if [ "`echo $xy|sed ...`" = "blabla bla" ];

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Giorgos Keramidas
On 2006-05-12 11:27, Chuck Swiger <[EMAIL PROTECTED]> wrote: >Giorgos Keramidas wrote: >> This fails to remove multiple occurences of the [[:space:]] class. >> >> There are at least the following ways: >> >> sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... >> perl -pi -e 's/^\s

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Chuck Swiger
Giorgos Keramidas wrote: This fails to remove multiple occurences of the [[:space:]] class. There are at least the following ways: sed -i -e 's/^[[:space:]]*' -e 's/[[:space:]]*$//' file ... perl -pi -e 's/^\s*(\S.*\S)[ \t]*$/$1/' file ... The first one seems more straightforwa

Re: Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Giorgos Keramidas
On 2006-05-12 09:50, Martin McCormick <[EMAIL PROTECTED]> wrote: > This looks like something sed should be able to do, but I > haven't had any luck at all. I wanted to remove any whitespace > that has accidentally gotten added to the beginning or end of > some lines of text. I made a test f

Trimming Whitespace From Beginning and end of Text Lines

2006-05-12 Thread Martin McCormick
This looks like something sed should be able to do, but I haven't had any luck at all. I wanted to remove any whitespace that has accidentally gotten added to the beginning or end of some lines of text. I made a test file that looks like: left justified.