Artificial intelligent assistant

Passing timestamp variable from shell to gawk I want to take time difference of two time stamp but getting an error while passing timestamp variable from shell to`awk`. Shell code: FTIMESTAMP="2015-07-01 12:30:50" gawk -v FTIMESTAMP=$FTIMESTAMP -v DSECONDS=$DSECONDS -f test.awk /home/abc/TShift.csv Error is: gawk: 12:30:50 gawk: ^ syntax error Escaping character is also not working `FTIMESTAMP="2015-07-01 12\:30\:50"`. I have another timestamp in `awk` and want to take time difference between them.

You need to quote variables to prevent shell from performing split+glob:


gawk -v FTIMESTAMP="$FTIMESTAMP" -v DSECONDS="$DSECONDS" ...


A note that `-v var="$shell_var"` will expand escape sequences in `$shell_var`. You need to use `ENVIRON` or `ARGV` variables to pass `$shell_var` as-is from shell to `awk`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 614c9d71d59ede3bf97e1eb547d2791e