Created
April 1, 2013 10:57
-
-
Save breyten/5284293 to your computer and use it in GitHub Desktop.
List a specific field of a tab separated file using AWK
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
#!/bin/sh | |
/usr/bin/awk ' | |
BEGIN { | |
FS="\t"; | |
FIELD_NAME="'$1'"; | |
print FIELD_NAME; | |
} | |
NR == 1 { | |
for(i=0;i<NF;i++){ | |
if ($(i)==FIELD_NAME) { | |
FIELD_NUM=i; | |
} | |
} | |
} | |
NR > 1 { | |
print $(FIELD_NUM) | |
}' $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment