Computing.Net > Forums > Unix > extract a specific line from file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

extract a specific line from file

Reply to Message Icon

Name: Aristo
Date: July 29, 2003 at 22:03:41 Pacific
OS: Unix
CPU/Ram: ?
Comment:

hi,

can anyone teach me how to extract a specific line from an input file?

what utility should I use?

btw, I'm using Bourne Shell.



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: July 29, 2003 at 22:25:11 Pacific
Reply:

It depends upon how you want to recognize the specific line. Do you want the fourth line from a file?? Do you want a line that contains a specific phrase?


0

Response Number 2
Name: Aristo
Date: July 29, 2003 at 22:29:47 Pacific
Reply:

just a normal line, not by delimeter...

for example, the 4th line of an input file..

thanks


0

Response Number 3
Name: f
Date: July 29, 2003 at 23:37:46 Pacific
Reply:

How about combination of head and tile in a pipe?
Say, you need 4th line:

head -n 4 your_file | tail -n 1



0

Response Number 4
Name: Aristo
Date: July 30, 2003 at 00:29:48 Pacific
Reply:

it works..

thank you very much.


0

Response Number 5
Name: David Perry
Date: July 30, 2003 at 08:04:00 Pacific
Reply:

lineno=10

sed -n ${lineno}p infile > outfile


0

Related Posts

See More



Response Number 6
Name: HRCafe
Date: August 5, 2003 at 05:45:21 Pacific
Reply:

How about extracting the last line of a file. For example, I'm ftp'ing a file from UNIX to an NT box and an extra line is being added to the end of the file on the NT box. All it is is a blank line. I'm guessing this is a tranmission issue but does anyone know how to correct it? Please let me know your thoughts... Thanks!!!


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: extract a specific line from file

removing specific line from file www.computing.net/answers/unix/removing-specific-line-from-file/5042.html

getting a specific line from a file www.computing.net/answers/unix/getting-a-specific-line-from-a-file/7708.html

Reading a specific line from file www.computing.net/answers/unix/reading-a-specific-line-from-file/3937.html