only output the nth line

Jake Peavy djstunks at gmail.com
Wed May 12 19:14:11 UTC 2010


On Wed, May 12, 2010 at 1:11 PM, Joachim Backes <
joachim.backes at rhrk.uni-kl.de> wrote:

> On 05/12/10 18:58, Jozsi Vadkan wrote:
>
>> I have a file:
>>
>> cat file.txt
>> daemon
>> 1):
>> 596
>> 0
>> 0
>> 1
>> 0
>> 0
>> bin
>> 2):
>> 12
>> 0
>> 0
>> 1
>> 0
>> 0
>> sys
>> 3):
>> 0
>> 0
>> 0
>> 0
>> 0
>> 0
>>
>>
>>
>> And i want to only output the first, second, and fourth line to another
>> file.
>>
>> The:
>>
>> sed -n '1,2p;4p' file.txt
>>
>> doesn't work.
>>
>> What magic do i need for it? :D
>>
>> Thanks..:\
>>
>>
> <file.text perl -e'while (<STDIN>) {print if $.==1 or $. == 2 or $. == 4;}'
>

or perl -ne 'print if grep {$. == $_} 1,2,4' file.txt

-- 
-jp

I wish I had a kryptonite cross, because then you could keep both Dracula
and Superman away.

deepthoughtsbyjackhandey.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/users/attachments/20100512/d7027b0c/attachment.html 


More information about the users mailing list