Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Searching for a command..., Improved cat.< Next Oldest | Next Newest >
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: July 27 2006,07:07 QUOTE

Is there any simple way to read a single line from a file?
Like command cat but just one line.

Example: command <line_number>


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: July 27 2006,15:40 QUOTE

Using awk...

For example to read/print the third line of the .filetool.lst file use:

awk 'NR = 3' .filetool.lst

Where NR is an internal variable of awk and is the number of records seen so far,
Back to top
Profile PM WEB 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: July 27 2006,19:32 QUOTE

For some reason that doesn't work for me.

What does work for me is grep -m3 ^ .filetool.lst|tail -1
or head -3 .filetool.lst|tail -1
sed would probably work too, but i don't know how.


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
roberts Offline





Group: Members
Posts: 4983
Joined: Oct. 2003
Posted: July 27 2006,19:53 QUOTE

Make sure you use two equal signs and not one

awk 'NR == 3' .filetool.lst
Back to top
Profile PM WEB 
Zucca Offline





Group: Members
Posts: 524
Joined: Feb. 2006
Posted: July 27 2006,20:05 QUOTE

Thank really much guys. This really helped me. :)

*starts to write his script*


--------------
Do you have it? - http://dy.fi/mak
Back to top
Profile PM WEB ICQ MSN 
7 replies since July 27 2006,07:07 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: Searching for a command...

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code