Created
March 22, 2017 03:42
-
-
Save kozross/9ffeb6af200f95d3a0c5450d0abb8afd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I have the following Gawk invocation, which correctly only prints certain fields of a file in a comma-separated list | |
# | |
# gawk -F ',' -v NLINES=$(wc -l < members.csv) 'NR > 1 { printf("%s", $4) } NR != nlines && NR > 1 { printf(",") }' members.csv | |
# | |
# I'm trying to translate this into an actual script, and I have the following: | |
#!/usr/bin/gawk -f | |
FS = "," | |
NLINES = system("wc -l <" ARGV[1]) | |
NR > 1 { printf("%s", $4) } | |
NR != NLINES && NR > 1 { printf(",") } | |
# However, this doesn't work correctly when invoked as 'script.awk members.csv' | |
# It instead dumps the whole line each time, followed by the count on a new line | |
# What went wrong in translation here? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment