fatal: expression for `>' redirection has null string value
above error occurs if variable i
is not set or defined
For example : see below
No error since variable is defined
[akshay@localhost tmp]$ awk 'BEGIN{s=123; print 12345>s}'
[akshay@localhost tmp]$ cat 123
12345
Error since variable s is not defined
[akshay@localhost tmp]$ awk 'BEGIN{print 12345>s}'
awk: fatal: expression for `>' redirection has null string value
Please check map.txt file,
I get result without any error like this
[akshay@localhost tmp]$ awk -F, 'FNR==NR{a[$3]=$1 FS $2;next}{for(i in a){c=substr($1,length($1)-1);split(a,d); if(c>=d[1]&& c<=d[2])printf("GENERAL,%s,,,,,%s,,,,,0\n",$1,$3)>i }}' map.txt abc.txt
[akshay@localhost tmp]$ for i in file*.txt; do echo $i; cat $i; done
file1.txt
GENERAL,512345700,,,,,10001,,,,,0
GENERAL,512345701,,,,,10001,,,,,0
GENERAL,512345702,,,,,10001,,,,,0
GENERAL,512345703,,,,,10001,,,,,0
GENERAL,512345704,,,,,10001,,,,,0
GENERAL,512345705,,,,,10001,,,,,0
GENERAL,512345706,,,,,10001,,,,,0
GENERAL,512345707,,,,,10001,,,,,0
GENERAL,512345708,,,,,10001,,,,,0
GENERAL,512345709,,,,,10001,,,,,0
GENERAL,512345710,,,,,10001,,,,,0
GENERAL,512345711,,,,,10001,,,,,0
GENERAL,512345712,,,,,10001,,,,,0
GENERAL,512345713,,,,,10001,,,,,0
GENERAL,512345714,,,,,10001,,,,,0
GENERAL,512345715,,,,,10001,,,,,0
GENERAL,512345800,,,,,10001,,,,,0
file2.txt
GENERAL,512345716,,,,,10001,,,,,0
GENERAL,512345717,,,,,10001,,,,,0
GENERAL,512345718,,,,,10001,,,,,0
GENERAL,512345719,,,,,10001,,,,,0
GENERAL,512345720,,,,,10001,,,,,0
GENERAL,512345721,,,,,10001,,,,,0
GENERAL,512345722,,,,,10001,,,,,0
GENERAL,512345723,,,,,10001,,,,,0
GENERAL,512345724,,,,,10001,,,,,0
GENERAL,512345725,,,,,10001,,,,,0
file3.txt
GENERAL,512345726,,,,,10001,,,,,0
GENERAL,512345727,,,,,10001,,,,,0
GENERAL,512345728,,,,,10001,,,,,0
GENERAL,512345729,,,,,10001,,,,,0
GENERAL,512345730,,,,,10001,,,,,0
GENERAL,512345731,,,,,10001,,,,,0
GENERAL,512345732,,,,,10001,,,,,0
GENERAL,512345733,,,,,10001,,,,,0
GENERAL,512345734,,,,,10001,,,,,0
GENERAL,512345735,,,,,10001,,,,,0
GENERAL,512345736,,,,,10001,,,,,0
GENERAL,512345737,,,,,10001,,,,,0
GENERAL,512345738,,,,,10001,,,,,0
GENERAL,512345739,,,,,10001,,,,,0
GENERAL,512345740,,,,,10001,,,,,0