Answer the question
In order to leave comments, you need to log in
Awk how to concatenate columns when passed to shell?
Good afternoon
4th field 15-Aug-2019
5th field 00:24:38 the
expression works
awk '{z=system("date --date="$4" +%s")} {printz}'
this is no longer
awk '{z=system("date --date="$4" "$5" +%s")} {printz}'
Try 'date --help' for more information.
date: extra operand '+%s'
Answer the question
In order to leave comments, you need to log in
$ echo "a1 a2 a3 15-Aug-2019 00:24:38 a6 ..." | awk '{z="date -d \""$4" "$5"\" \"+%s\""; z | getline z; print z}'
1565817878
$ echo "a1 a2 a3 15-Aug-2019 00:24:38 a6 ..." | awk '{z="date -d \""$4" "$5"\" \"+%s\""; z | getline z; $4=z;$5="";print}'
a1 a2 a3 1565817878 a6 ...
$ echo "a1 a2 a3 15-Aug-2019 00:24:38 a6 ..." | awk '{"date -d \""$4" "$5"\" \"+%s\""|getline $4;$5="";print}'
a1 a2 a3 1565817878 a6 ...
$ echo "a1 a2 a3 15-Aug-2019 00:24:38 a6 ..." | awk '{"date -d \""$4" "$5"\" \"+%s\"" | getline z; $4=z;$5="";print}'
a1 a2 a3 1565817878 a6 ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question