3 ms·
Very eye opening presentation and good exercises in the second video! I had no understanding of awk whatsoever and can now fully grok the following command, wh
by zubspace 6y ago
Very eye opening presentation and good exercises in the second video!
I had no understanding of awk whatsoever and can now fully grok the following command, which returns the number of different cities in a structured file with a header line, addresses and the city in column 5:
awk 'NR != 1 { print $5 }' payroll.tsv | sort | uniq | wc -l
This is beautiful.
- davidgould 6y agoAlmost. It doesn't handle multi word cities, eg "San Franciso", and it spawns extra processes. Try: awk -F "\t" 'NR != 1 { if (!cities[$5]++) n++ } ; END { print n }' payroll.tsv
- deleted 6y ago[deleted]