Extract out lines with “s__” into a new file together with first two lines of the file

I have a file from where I want to extract the first two lines (starting with "ID" and "#SampleID") along with all the lines that contain "s__" in that line. And, want to put them in a new file. Can anyone please tell me how can I do that?

0
задан 22 July 2020 в 00:10

2 ответа

grep -m2 "" your.file > test.txt; grep "s__" your.file >> test.txt
0
ответ дан 30 July 2020 в 22:04
awk 'NR<3 || /s__/' yourfile > newfile

или

sed -n -e '1,2p' -e '/s__/p' yourfile > newfile
2
ответ дан 30 July 2020 в 22:04

Другие вопросы по тегам:

Похожие вопросы: