Recipes, scripts and genomics
Pages
Home
About
Relevant Links
Friday, November 19, 2010
Getting nth line in a file
Ever wondered what is the nth line of a file without using a text editor ?
Here is something you may use in a unix environment.
sed -n '5 p' file1.txt
this sed one-liner outputs the 5th line of the file1.txt
1 comment:
frenkiboy
November 19, 2010 at 4:05 PM
Another easy solution is:
head -n 5 file.txt | tail -n 1
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Home
Subscribe to:
Post Comments (Atom)
Another easy solution is:
ReplyDeletehead -n 5 file.txt | tail -n 1