Looking to set a date variable withing awk but can't get the quoting or syntax right!
awk -v c=$i -v d="date +\"%D %r %Z\"" '{print d c }'
Looking to set a date variable withing awk but can't get the quoting or syntax right!
awk -v c=$i -v d="date +\"%D %r %Z\"" '{print d c }'
Consider instead:
awk -v d="$(date +'%D %r %Z')" 'BEGIN{print d}'
The changes here are:
$()
to execute date and get the output back for the variable d
. date
format so you don't have double quotes in double quotesBEGIN
to execute the print
statement in awk. This isn't necessary if you are feeding a file or stdin to awk for it to read records.