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.
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 file
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
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*(\S.*\S)[
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 ]; then ...
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 what I was
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 readable.
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
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:
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 the problem
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 more
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
12 matches
Mail list logo