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?

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

2 ответа

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


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

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

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