Reputation: 263
I have a big file look like the example:
chr1:16872433-16872504 54 112622
chr1:16872433-16872504 55 112110
chr1:16872433-16872504 56 110996
chr1:16872433-16872504 57 110306
chr1:16861773-16861845 20 38808
chr1:16861773-16861845 21 39768
chr1:16861773-16861845 22 40344
chr1:16861773-16861845 23 40637
chr1:16861773-16861845 24 41311
chr2:7990338-7990408 8 0
chr2:7990338-7990408 9 0
chr2:7990338-7990408 10 0
chr2:7990338-7990408 11 0
chr2:7990338-7990408 12 0
I want to extract every part starting with "chr1:16872433-16872504
" and make a new .txt
file.
how can I do that in bash? I tried grep
command but I do not know how to make it conditional.
Upvotes: 0
Views: 48
Reputation: 1872
grep -E 'chr1:16872433-16872504' your.txt > new.txt
gives you the following output
chr1:16872433-16872504 54 112622
chr1:16872433-16872504 55 112110
chr1:16872433-16872504 56 110996
chr1:16872433-16872504 57 110306
as per your requirement ["chr1:16872433-16872504"]
Upvotes: 1