4 Mar 2006 01:03
Re: Delete Blank Lines
Cameron Simpson <cs <at> zip.com.au>
2006-03-04 00:03:42 GMT
2006-03-04 00:03:42 GMT
On 03Mar2006 13:08, Skeer, Jay <jaysk <at> amazon.com> wrote:
| If you don't have the in place option, how about:
|
| find . -type f -exec sed -n '/^$/!w/var/tmp/tempfile' {} \; -exec mv /var/tmp/tempfile {} \;
Indeed. I have a shell script called bsed here:
http://www.cskk.ezoshosting.com/cs/css/bin/bsed
That does essentially that, that I use in preference to the non-portable
"sed -i". You run it pretty much like "sed -i", but it really does edit
in place (sed -i does what your find command does, which replaces the
file with a _different_ file, rather than overwriting; thus "sed -i"
will break hardlinks and permissions etc).
Eg:
bsed '/^$/d' filenames...
or
find . -type f -print | xargs bsed '/^$/d'
Cheers,
--
Cameron Simpson <cs <at> zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/
For reading rec.moto, I use one of those carbon-fiber Logitech mice w/a
little 'No Fear' sticker on it. - Mike Hardcore DoD#5010 <moike <at> netcom.com>
Apologies to Primus
--
--
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/
<*> To unsubscribe from this group, send an email to:
sed-users-unsubscribe <at> yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
RSS Feed