madasafish
Technical User
I have several files with dates in different fields and would like to assign an external variable "$datefield" different awk fields ie: $1 $2...etc..
#!/bin/bash
starttxt=DATASTART
endtxt=DATAEND
filetype=adf
filedir=$workdir/bin
paramfile=$workdir/param.adf.dat
datefield='"$3"'
for pfile in `ls -1 $filedir/*.$filetype`
do
gawk -v file="$pfile" \
-v start="$starttxt" \
-v end="$endtxt" \
-v datefield="$datefield" \
'{
if ($1 == start)
{
gsub(/"/,"")
printf "%-60s %-20s", file, datefield
}..................etc
I would like awk to see the line..
printf "%-60s %-20s", file, datefield
as
printf "%-60s %-20s", file, $3
Any help appreciated,
Many thanks,
Madasafish
#!/bin/bash
starttxt=DATASTART
endtxt=DATAEND
filetype=adf
filedir=$workdir/bin
paramfile=$workdir/param.adf.dat
datefield='"$3"'
for pfile in `ls -1 $filedir/*.$filetype`
do
gawk -v file="$pfile" \
-v start="$starttxt" \
-v end="$endtxt" \
-v datefield="$datefield" \
'{
if ($1 == start)
{
gsub(/"/,"")
printf "%-60s %-20s", file, datefield
}..................etc
I would like awk to see the line..
printf "%-60s %-20s", file, datefield
as
printf "%-60s %-20s", file, $3
Any help appreciated,
Many thanks,
Madasafish