Hi,
If I run the following two commands in two separate bash sessions
concurrently, output.txt will contain messed up results from both awk
runs.
awk -e 'BEGIN { for(i=1;i<10;++i) { print 100+i; system("sleep 1"); }
}' > output.txt
awk -e 'BEGIN { for(i=1;i<10;++i) { print i; system("sleep 1"); } }' >
output.txt
Is there a bash syntax to lock output.txt that ensuring the file
redirected by ">" is not written concurrently by more than one
process? Thanks.
--
Regards,
Peng