views:

22

answers:

2

Hey guys,

I have a simple question. Is there a command that allows you to pull a certain line out of an input? Like if I wanted the 7th line from ifconfig. Is there a way to do this: ifconfig | [command] 7?

Thanks!

+1  A: 

This should do it

ifconfig | head -n 7 | tail -n 1

6502
Thanks a lot for the help!
hassaanm
Or, slightly more succinctly: `ifconfig | head -7 | tail -1`
Paul R
+1  A: 

YOu can use sed to extract a particular line from a file and/or from standard in as follows

sed -n '7p' filename or

some_command | sed -n '7p'
Steve Weet