Reputation: 64004
How can I get second line in a file using SED
@SRR005108.1 :3:1:643:216
GATTTCTGGCCCGCCGCTCGATAATACAGTAATTCC
+
IIIIII/III*IIIIIIIIII+IIIII;IIAIII%>
With the data that looks like above I want only to get
GATTTCTGGCCCGCCGCTCGATAATACAGTAATTCC
Upvotes: 41
Views: 82747
Reputation: 12025
You don't really need Sed, but if the pourpose is to learn... you can use -n
n read the next input line and starts processing the newline with the command rather than the first command
sed -n 2p somefile.txt
Edit: You can also improve the performance using the tip that manatwork mentions in his comment:
sed -n '2{p;q}' somefile.txt
Upvotes: 54
Reputation: 96258
This will print the second line of every file:
awk 'FNR==2'
and this one only the second line of the first file:
awk 'NR==2'
Upvotes: 16
Reputation: 43219
You always want the second line of a file? No need for SED:
head -2 file | tail -1
Upvotes: 23