Domanda

I have a nawk command as shown. Can anyone explain what this command is suppose to do.

set sampFile = $cur_dir/${qtr}.SAMP

nawk -F "," '{OFS=","; if (($4 == "0000" || $4 == "00000000")) {print $0} }' $samp_input_file >! $sampFile
È stato utile?

Soluzione

Given a CSV file pointed to by the variable $samp_input_file this command will print the lines where the 4th field is either 0000 or 00000000 and store the output in the file pointed to by $sampFile.

1,2,3,00
2,2,3,0000
3,2,3,000
4,2,3,00000000
5,2,3,0000

# Cleaner version 
awk '{FS=OFS=","; if ($4 == "0000" || $4 == "00000000") print}' file
2,2,3,0000
4,2,3,00000000
5,2,3,0000
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top