Guys I placed
#!path/awk -f
placed awk script
and used $1 to call 1st inputfile inside the script.
But some where I did mistake. Could you please help me run this script as executable
I forgot to mention I also used BEGIN before placing awk script. But nothing worked out.
Script
#!/usr/bin/awk
'NF {
sec = $2; fifth = split($5, _fifth, ","); sixth = split($6, _sixth, ",")
counter = rec = ""; key = $1; flag = $4; sub(/[^ \t*]*/, "")
dummy = sprintf("%*s", length(key),x)
for (i=1; i<=sixth; i++) {
second_third = sec + _sixth FS _fifth + sec + _sixth
third_second = sec + _sixth FS _fifth + sec + _sixth
if (flag == "+")
rec = rec ? rec RS dummy OFS second_third : key OFS second_third OFS $0
else if (flag == "-")
rec = rec ? rec RS dummy OFS third_second : key OFS third_second OFS $0 }
print (flag == "+" ? rec : rec)
}' OFS='\t' ORS='\n' $1
---------- Post updated at 01:49 AM ---------- Previous update was at 01:47 AM ----------
Just incase if you need
Input
X1 84 140 - 4,10,4 0,36,52
X1 20 110 + 5,10,5 0,35,90