I'm writing a SHELL script that will call an AWK script file printing specific fields based on the options specified by the user from the .sh script
EXAMPLE
-N=field with a list of Names ==> is the field number 2
-A=field with a list of Addresses ==> is the field number 4
-P=field with a list of Prices ==> is the field number 6
-D=field with a list of Dates ==> is the field number 10
./SHELLSCRIPT.sh -N -A -P -D
NAMES,ADDRESSES,PRICES,DATES
NAMES,ADDRESSES,PRICES,DATES
NAMES,ADDRESSES,PRICES,DATES
EXAMPLE
./SHELLSCRIPT.sh -N -D
NAMES,DATES
NAMES,DATES
NAMES,DATES
I'm trying to initialize a variable inside AWK using the -v option passing the number of fields but I'm having some difficulties on printing it...
here is the AWK script:
#!/usr/bin/awk -f
BEGIN {
FS="\",\"" ;
-v test=2,4,6,10
for (i in test)
print $test[i];
}
AWK script must exclude some field/s when the user doesn't specify some option/s in the shell script.
-vfor awk, you can't be too far away from a working solution. Add your code and we can help you, other wise you're expecting us to play 20 questions with you. Good luck.-vbefore each and every one - caught me out before now!!!split(test,inArr, ","); for(i in inArr) ...Good luck to all.