Skip to content

Instantly share code, notes, and snippets.

@rohitprajapati
Last active February 19, 2016 08:14
Show Gist options
  • Save rohitprajapati/714efac149fcd7b5c144 to your computer and use it in GitHub Desktop.
Save rohitprajapati/714efac149fcd7b5c144 to your computer and use it in GitHub Desktop.
Multiple input file awk command.
# Usage: awk -f multiple_input_file.awk ~/Desktop/test_1.csv ~/Desktop/test_2.csv
BEGIN {
FS = ","
OFS = ","
}
FNR == 1 {
FILE_NUM++
}
FILE_NUM == 1 && FNR > 1 {
a = $1 "-" $3 "-" $2
x[a] = 1
}
FILE_NUM == 2 && FNR > 1 {
b = $1 "-" $2 "-" $3
if (!x[b]) {
print b
} else {
print "############################## " b
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment