I have a tab- separated file with many rows like this :
1 ILM-rs199 info1 info2 info3
2 aws-rs2778 info4 info5 info6
3 345-678945 info7 info8 info9
4 aws-rs789 info10 info11 info-rs789
I want to extract 2nd and 4th column and in the second column I want only the string starting with rs and the numbers following it like this :
rs199 info2
rs2778 info5
rs789 info11
I was able to extract the second column alone with the following command:
egrep -o 'rs[0-9]*' filename
gives
rs199
rs2778
rs789
but I got stuck when I had to also keep the other columns
I was thinking of using egrep (for extracting rs nos in 2nd column) inside awk but could'nt finish it.
-
before the rsID? And is your file space-delimited or do you have tabs?-
then, my original answer depended on that. By the way, you might be interested in our new sister site, Bioinformatics.rs
in the second column? What should happen there? Please take a few minutes and think about all the possible cases. Making constant changes that invalidate our answers means we will be wasting your time (and ours) giving you solutions that don't work for your data.