I am just new to the script language.
Now I have a file, inside it are:
> A1 B1 C1
> A2 B2 C2
> A3 B3 C3
I just want to use the shell script(bash) to read the file element by element. Then I want to do some calculation of the element A1, A2 and A3 and then write them back to a new file(or the old file). So the new file would be (supposed the calculation results are D1,D2 and D3):
D1 B1 C1
D2 B2 C2
D3 B3 C3
The calculation is to convert the Unix epoch time(A's value) into human readable time(D's value) by command "date -d @(A's value)".
I try to use the awk command:
awk '{$1=`date -d @$1`}' test.txt
But it seems to have some syntax error:> The error is :
awk: {$1=`date -d @$3`}
awk: ^ invalid char '`' in expression
your requirement is so unclear! what calculation did you mean?
I could show you an example, hope it helps:
Edit
here I could give you an example how to invoke
date
in awk:I guess that is what you are looking for.
good luck.
If you need to use UNIX date on this instead of gawks builtin time functions, then just do it all in shell:
Use gawk if possible though.