I need help on AWK scripting to do some actions as follows:
- Parsing File,
- Do some calculation, or Execute External Program,
- Write the Output into Separated Files
I have an input file (say, input.txt) consists of this data:
I need my AWK script to read some values of it.
Those values are:
- $1 (id)
- $5 (status)
- $6 (date)
- $7 (time), and
- $8 (location)
For each record of the input file which has "qw" on $5, this script will create a file named $1.data (for each record) to store a value calculated based on the current system time and $6 + $7 on the record.
Meanwhile, for each record which has "r" as status ($5), the script will execute an external program (sh script) using those values as parameters. This external program will give a string as return value. And then this AWK script will also create a file named $1.data (for each record) to store this return value.
On this case, the AWK script will create 3 output files:
- 834608.data with return-string-value from an external program as the content.
- 834609.data and 834610.data with calculated values as the content
Anybody can help me on this problem?
Many thanks in advance.
- Parsing File,
- Do some calculation, or Execute External Program,
- Write the Output into Separated Files
I have an input file (say, input.txt) consists of this data:
Code:
834608 0.50500 openssl-sp ampra2 r 04/18/2011 09:26:18 all.q@east-32.enterprisegrid.e 1
834609 0.55500 openssl-sp ampra2 qw 04/18/2011 14:43:03 1
834610 0.55500 openssl-sp ampra2 qw 04/18/2011 14:43:05 1
I need my AWK script to read some values of it.
Those values are:
- $1 (id)
- $5 (status)
- $6 (date)
- $7 (time), and
- $8 (location)
For each record of the input file which has "qw" on $5, this script will create a file named $1.data (for each record) to store a value calculated based on the current system time and $6 + $7 on the record.
Meanwhile, for each record which has "r" as status ($5), the script will execute an external program (sh script) using those values as parameters. This external program will give a string as return value. And then this AWK script will also create a file named $1.data (for each record) to store this return value.
On this case, the AWK script will create 3 output files:
- 834608.data with return-string-value from an external program as the content.
- 834609.data and 834610.data with calculated values as the content
Anybody can help me on this problem?
Many thanks in advance.