2011年9月10日星期六

linux command - select a subset of lines in a file

What if the lines you want to extract are not in sequence, say lines 1 to 2, and line 4?

$ sed -n -e 1,2p -e 4p somefile.txt
Line 1
Line 2
Line 4

没有评论:

发表评论