Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 May 2006 12:38:42 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Giorgos Keramidas <keramida@ceid.upatras.gr>
Cc:        Martin McCormick <martin@dc.cis.okstate.edu>, freebsd-questions@freebsd.org
Subject:   Re: Trimming Whitespace From Beginning and end of Text Lines
Message-ID:  <20060512122847.F16342@wonkity.com>
In-Reply-To: <20060512170406.GE26040@gothmog.pc>
References:  <200605121450.k4CEokhn022089@dc.cis.okstate.edu> <20060512150608.GB25497@gothmog.pc> <20060512102134.J14220@wonkity.com> <20060512170406.GE26040@gothmog.pc>

next in thread | previous in thread | raw e-mail | index | archive | help
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 message.  You're right, of course :)
>
> It seems odd that the fixed expression doesn't work though.
> Which version of FreeBSD is this and what sed are you running?
>
> 	$ uname -v

FreeBSD 4.11-STABLE #0: Wed Mar 22 19:18:33 MST 2006

> 	$ type sed

That's a sh-ism (normally I use csh):

sed is /usr/bin/sed

Interestingly, the problem is different on 6.1 (csh or sh):

sed -i -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' test.txt
sed: -e: No such file or directory

...which is solved by giving a blank argument for -i:

sed -i'' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' test.txt

Gah.

-Warren Block * Rapid City, South Dakota USA



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060512122847.F16342>