I am using something like this in my code
nawk 'BEGIN{OFS=FS="|"} {$15='$CalaMig'} {print}' filename
actually value of $CalaMig=01234
But its replacing as 1234 in the 15th postion.Its not taking the first zero.
can some one help here
I am using something like this in my code
nawk 'BEGIN{OFS=FS="|"} {$15='$CalaMig'} {print}' filename
actually value of $CalaMig=01234
But its replacing as 1234 in the 15th postion.Its not taking the first zero.
can some one help here
Try using sprintf.
i.e.
$ CalaMig=123
$ echo 1 2 3 | awk '{$2 = sprintf("%05d", '$CalaMig')}1'
1 00123 3
Otherwise, using quoting:
$ CalaMig=0123
$ echo 1 2 3 | awk '{$2 = "'$CalaMig'"}1'
1 0123 3