chilecayenne
Programmer
Hello all,
I'm making progress on my first awk script in a LONG time.
I'm trying to now make it a bit more versitile...and send in file names as variables on the command line, rather than hard coded in, but I'm having problems.
Example...this works
BEGIN {
FS="|";
OFS="|";
while (getline < "dev_bxm_link_output.txt" > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
This works just fine when I have the file going into getline hard
coded in.
However when I try something like this:
BEGIN {
FS="|";
OFS="|";
while (getline < v_filename > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
And when calling awk sending the v_filename as a variable...it gives
me an error of:
fatal: expression for `<' redirection has null string value
I'm calling this like:
awk -f myawkfile.awk v_filename="file1.txt" file_to_process.csv
Thanks in advance,
chilecayenne
Any
I'm making progress on my first awk script in a LONG time.
I'm trying to now make it a bit more versitile...and send in file names as variables on the command line, rather than hard coded in, but I'm having problems.
Example...this works
BEGIN {
FS="|";
OFS="|";
while (getline < "dev_bxm_link_output.txt" > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
This works just fine when I have the file going into getline hard
coded in.
However when I try something like this:
BEGIN {
FS="|";
OFS="|";
while (getline < v_filename > 0)
{
split ($0,bxm_rec,"|");
b_memrecno1 = bxm_rec[2];
b_memrecno2 = bxm_rec[3];
b_score = bxm_rec[5];
bxm_array[b_memrecno1,b_memrecno2] = b_score;
}
}
And when calling awk sending the v_filename as a variable...it gives
me an error of:
fatal: expression for `<' redirection has null string value
I'm calling this like:
awk -f myawkfile.awk v_filename="file1.txt" file_to_process.csv
Thanks in advance,
chilecayenne
Any