I have written many awk commands which go in multiple lines.
I have this confusion many times.
Some time they work if i dont terminate them with "\" but some time error.
Some time in "if" statements between if and else if i dont use ";" it gives error but sometimes it doesnt.
The below code if i dont use ";" it gives error.
nawk -F"|" 'NR==FNR{a[$1]=$7 OFS $6;next} {\
if (a[$2]) \
print $1 OFS a[$2]; \
else \
print $1 OFS $3}' OFS="|" \
file1 file2
In the below code i am not using ";" between if and else if but it works
nawk -F"|" '{ \
if ($3 ~ "hm." && $5 == "" && $6 == "" && $7 == "") \
{$9="Not";print $1,$2,$8,$9 } \
else if ($3 !~ "hm." && $5 == "" && $6 == "" && $7 == "") \
{$9="yes";print $1,$2,$8,$9} \
else {print $1,$2,$3,$7,$8}}' OFS="," \
file
Appreciate help in clarifing where to use ";" and "\'