Awk judges and outputs all rows that meet the conditions according to the penultimate column
Awk judges and outputs all rows that meet the conditions according to the penultimate column
$NF
Represents the last numberThe penultimate line means $(NF-1)
remember to add parentheses
-F','
Use comma as separator
wc -l
Count the number of eligible rows
cat data.csv | awk -F',' '{if($(NF-1) == 1){ print $0}}'
cat data.csv | awk -F',' '{if($(NF-1) == 1){ print $0}}' | wc - l
Statistics rows
After a long time, I found that it was inseparable from shell data processing. Large files cannot be opened in win.
Keep learning~