Reputation: 25
I have this awk command that I need to put a date variable in. I'm sure I'm missing some syntax somewhere. Can any experts help me out? Basicaly, I need the date to be variable depending on when the script is run.
date=$(date --date="1 month ago" +"%d-%b-%Y")
wget -qO - http://*********/users.csv > users
awk 'NR==1 {print "Primary Comments,Customer Account Number,Transaction Date,Service Description,Quantity,Unit,Price,Service Category,PI\x27sName,Purchaser\x27s Last Name,Short Contributing Center Name,Resource Name,Line Item Assistant,Line Item Comments"}
FNR==NR {S[$1]=$2; P[$1]=$3; next}
$1 in S {print "Bruker 500 NMR",P[$1],date,"500 MHz",$2/60,"Hour","5","500 MHz",S[$1],$1,"","501 NMR","","" }
' FS="," OFS="," OFMT="%.2f" $date users FS=" " wtmp > billing-$inst-$date.csv
Upvotes: 2
Views: 278
Reputation: 33307
Use the -v
option.
awk -v date="$date" ....
But GNU awk (gawk
) has its own time functions, which are documented here: http://www.gnu.org/software/gawk/manual/html_node/Time-Functions.html
Upvotes: 5