Reputation: 81
I have a file called autodata.csv and has 20 columns of data. I am looking to print only the rows with "6" being in column 8 (for cylinders).
So, I have this working but only printing the number 6, rather than all the columns:
#!/bin/bash
while read x
do
echo $x | awk -F ',' ' { print $8=6} '
done
But if I add the rest of the columns it gives me errors:
echo $x | awk -F',' ' { print $1":"$2":"$4":"$7":"$8=6}'
Upvotes: 0
Views: 867
Reputation: 11061
Something like this, perhaps?
awk -F ',' '{ if ($8 == 6) { print $1":"$2":"$4":"$7":"$8 } }'
Upvotes: 3