Re: Q for Unix guru's

From: Charles Demas (demas_at_TheWorld.com)
Date: 07/27/03


Date: Sun, 27 Jul 2003 01:12:56 +0000 (UTC)

In article <kNCUa.848$Bg.427@newsread4.news.pas.earthlink.net>,
Alan Connor <alanconnor@earthlink.net> wrote:
>On Sat, 26 Jul 2003 19:42:10 +0000 (UTC), Charles Demas
><demas@TheWorld.com> wrote:
>>
>>
>> In article <594f6d6f.0307261059.17f0ceb9@posting.google.com>,
>> Spider-X <yedilw@yahoo.com> wrote:
>>>what combination of grep sed cat and wc would I have to use to count
>>>the number of lines in a file that exceed 50 characters?
>>
>> grep and wc
>>
>>>If this is
>>>easy enough, then how do I print all the lines that exceed this limit
>>>to its own file?
>>
>> awk 'length > 50' infile > outfile
>>
>> This sounds so much like homework!
>>
>>
>> Chuck Demas
>>
>
>Doesn't it....
>
>
>sed -n '/................................................../p' infile > outfile
>
>Looks silly, but works great. Less resources and faster than awk too :-)
>

sed -n '/.\{51\}/p' infile > outfile

is less silly looking but this is shorter:

grep '.\{51\}' infile > outfile

but that would be doing the homework for him. :-(

Chuck Demas

-- 
  Eat Healthy        |   _ _   | Nothing would be done at all,
  Stay Fit           |   @ @   | If a man waited to do it so well,
  Die Anyway         |    v    | That no one could find fault with it.
  demas@theworld.com |  \___/  | http://world.std.com/~cpd


Relevant Pages