[nylug-talk] need sed help

Steven Lembark lembark at wrkhors.com
Wed Apr 4 15:45:46 EDT 2007


Peter C. Norton wrote:
> On Wed, Apr 04, 2007 at 03:22:08PM -0400, Steven Lembark wrote:
>> Why not use perl:
>>
>>   perl -p -e 's/^\s+//' in.txt > out.txt;
>
> That's going to work on more than just the first line. Eg. it is wrong.

Oops, forgot to slurp the thing:

  perl -p -e 'BEGIN{ undef $/ } s/^\s+//' in.txt > out.txt;


e.g.,

$ echo -e "   foo\n   bar\n   bletch\n" |
perl -p -e 'BEGIN{ undef $/ } s/^\s+//' ;

foo
   bar
   bletch




-- 
Steven Lembark                                         85-09 90th Street
Workhorse Computing                                  Woodhaven, NY 11421
lembark at wrkhors.com                                      +1 888 359 3508


More information about the nylug-talk mailing list