I am defining the following variables inside a bash script (note: I ultimately want to pass these values to the bash script from the commandline but I haven't gotten that far yet):
OFS=','
INPUTFILE='~/data.txt'
OUTPUTFILE='~/delimited.txt'
FIELDWIDTHS='1 10 4 2 2'
Next, inside the bash script I'm attempting to call an awk script and pass it these same values:
echo
echo | awk -v FIELDWIDTHS=$FIELDWIDTHS -v OFS=$OFS
-v INPUTFILE=$INPUTFILE -v OUTPUTFILE=$OUTPUTFILE
-f ~/bin/fixedWidthToDelimited.awk
The awk script doesn't seem to be able to understand correctly what's being passed to it, I keep getting fatal errors. Can someone please help me understand how to do this? Thanks!