Improve script and get new output file

In your latest script, change:

awk '

to:

awk -v DbDir="$offsetDbDir" '

and change:

                 while (1 == getline LINE < (find $offsetDbDir/ -type f -iname $swath"offb1-Sx.sps"))

to:

                 while (1 == get line LINE < (DbDir swath "offb1-Sx.sps"))

Your modification failed because:

  1. Shell variables aren't available inside awk scripts.
  2. Shell command substitution doesn't work inside awk scripts.
  3. In awk variable values are substituted by referencing their names; not by $ followed by their names as in the shell command language.

But this will only work if the filename you are reading matches the name specified exactly; it won't do a case-insensitive match unless the file resides on a filesystem that is case insensitive.

1 Like

Don Cragun.

Thanks it works fine.. Thanks a lot for the explanation.