I have data where there are multiple values in a single column, each separated by a comma. I want to print the ID in the first column, and print values in the third column that are greater than 199. I also want to print the ID even if there are no values greater than 199. Also, the columns do not all have the same number of values.
I think awk is probably the right tool to get there, but I’m not sure where to start since I haven’t found any examples for this.
Here’s an example of what the data looks like:
ID1 A:1,0,0,0,16,9,0,0,3,4,5 B:4,98,207,89,255,106,65,122,77,90,202
ID3 A:5,0,0,3,19 B:32,195,238,84,140
ID4 A:9,0,0,1,2,3 B:196,53,29,174,132,88
ID9 A:4,0,0,0,0,7,8,1 B:9,81,228,245,172,49,61,113
and I’d like to retain the ID and values greater than or equal to 200. I’d like the final data to look something like:
ID1 207,255,202
ID3 238
ID4
ID9 228,245
I haven’t ran any commands to attempt this yet because I’m lost on where to start.
user26506410 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.