Re: only output the nth line
On Wed, 2010-05-12 at 18:58 +0200, 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..:\ Perhaps you need to redirect the output to the second file :) '' if you can overwrite the second file: sed -n '1,2p;4p' file.txt 2nd_file.txt or if you want to append to it: sed -n '1,2p;4p' file.txt 2nd_file.txt Cheers Calin Key fingerprint = 37B8 0DA5 9B2A 8554 FB2B 4145 5DC1 15DD A3EF E857 = Things fall apart; the centre cannot hold. -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Re: only output the nth line
On Wed, 12 May 2010 18:58:56 +0200 Jozsi Vadkan jozsi.avad...@gmail.com 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..:\ -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines You can try some awk, methinks; I don't remeber how to do it, but I say it's a good direction. -- Rares Aioanei fedora.lis...@gmail.com -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Re: only output the nth line
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;}' -- Joachim Backes joachim.bac...@rhrk.uni-kl.de http://www.rhrk.uni-kl.de/~backes smime.p7s Description: S/MIME Cryptographic Signature -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Re: only output the nth line
On Wed, 2010-05-12 at 18:58 +0200, Jozsi Vadkan wrote: 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. Works for me. What does it do on your system? poc -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Re: only output the nth line
On Wed, May 12, 2010 at 1:11 PM, Joachim Backes joachim.bac...@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 -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Re: only output the nth line
On Wed, 2010-05-12 at 20:07 +0300, Rares Aioanei wrote: You can try some awk, methinks; I don't remeber how to do it, but I say it's a good direction. awk 'NR == 1 || NR == 2 || NR == 4 { print }' file.txt birger -- users mailing list users@lists.fedoraproject.org To unsubscribe or change subscription options: https://admin.fedoraproject.org/mailman/listinfo/users Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines