Rabu
1
Hello everyone, I have a dataset that looks something like:
1 3
2 2
3 4,5
4 3:9
5 5,9
6 5:6
I need to remove the rows that contain a comma in the second column and I'm not sure how to go about this. Here is an attempt.
awk 'BEGIN {FS=" "} { if ($2!==,) print }'
Any help is appreciated.
awk '$2~/,/ {next} {print}' oldfile > newfile
You can use the ~ (match operator) on a field like $2
Try
awk '{ split($2, subfield, ","); if ( length(subfield)<2) print $0 }'
Your egrep approach will also delete lines with commas other than 2nd col?
Yoda
6
Yes, egrep
approach will work only on the sample input posted.