I have a simple script to format a file which I got to work using the
awk -f scriptname.awk inputFilename > outputfilename
It looks like this:
awk '
BEGIN {FS=","}
{ # loop through fields printing them in 50 char width slots
for (i=1; i<=NF; i++) {
printf("%-50s\t", $i)
}
printf("\n"
}' $*
Now I am trying the "wrapper" approach and cannot figure out how to output my results to file... Here is what I have:
#! /usr/bin/awk -f
BEGIN {FS=","}
{ # loop through fields printing them in 50 char width slots
for (i=1; i<=NF; i++) {
printf("%-50s\t", $i) >> OutputFile
}
printf("\n" >> OutputFile
}
It gives me this error even when I have created the OutputFile in advance:
awk: null file name in print or getline
awk -f scriptname.awk inputFilename > outputfilename
It looks like this:
awk '
BEGIN {FS=","}
{ # loop through fields printing them in 50 char width slots
for (i=1; i<=NF; i++) {
printf("%-50s\t", $i)
}
printf("\n"
}' $*
Now I am trying the "wrapper" approach and cannot figure out how to output my results to file... Here is what I have:
#! /usr/bin/awk -f
BEGIN {FS=","}
{ # loop through fields printing them in 50 char width slots
for (i=1; i<=NF; i++) {
printf("%-50s\t", $i) >> OutputFile
}
printf("\n" >> OutputFile
}
It gives me this error even when I have created the OutputFile in advance:
awk: null file name in print or getline