Hi All,
I am using SunSolaris machine.
I need to get the value of environment variable from awk begin. Then use that value as the start number of a sequence and use that in my print statement. But it is not reading the value from environment variable.
I have tried the following:
Calling script:
echo Starting
awk -f generatesequence.awk $1 > $2.csv
echo finish
Note: $1 is the input file to be read and $2 is the output file the output is redirected
Called script:
BEGIN {
FS="\""
x=0
STR="Starting_string"
VAR=ENVIRON["HOME"]
}
/^Event/ { x=x+1 }
/^Event/ { VAR=VAR+1 }
/^Event/ { print STR","x","$2","VAR }
Note: I am getting blank value into variable VAR even though I export the environment variable HOME in UNIX as "export HOME=100".
I am getting the output file data as
Starting_string,1,0667181535,1
Starting_string,2,0667181535,2
Starting_string,3,0667181535,3
But I expect it to come something as
Starting_string,1,0667181535,101
Starting_string,2,0667181535,102
Starting_string,3,0667181535,103
Thanks in advance.
prashas_d