I have a bash script that work fine with two awk statement, and I can visualize the outputs in the console for both statement but when I want to store the result in one file, I can get only one (it looks like a race sometimes the result of the statement 1 is stored sometimes the result of the statement 2). My code is like this
awk -F "," '
BEGIN {
print" ===================================================================== "
{printf "%80s\n", "Table 1" }
print"======================================================================= "
}
##process table 1
END {
print " ####### END TABLE 1 ##################\n\n\n "
} ' >file.txt
###### 2nd statement
awk -F "," '
BEGIN {
print" ====================================================== "
{printf "%80s\n", "Table 2" }
print"========================================================== "
}
##process table 2
END {
print "################END TABLE 2 ######################3 \n\n\n "
} ' >file.txt