Ask Ubuntu Asked by deep771992 on November 14, 2021
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?
grep -m2 "" your.file > test.txt; grep "s__" your.file >> test.txt
Answered by WU-TANG on November 14, 2021
awk 'NR<3 || /s__/' yourfile > newfile
or
sed -n -e '1,2p' -e '/s__/p' yourfile > newfile
Answered by steeldriver on November 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP