I have one input file ABC.txt and one output DEF.txt. After the ABC is processed and created output, I want to rename ABC.txt to ABC.orig and DEF to ABC.txt. Currently when I am doing this, it does not process the input file as it cannot read and write to the same file. How can I achieve this?
Is it possible if I can put a time interval between the awk script and mv commands??
what exactly is the error and what exactly is your awk script doing?
As it looks, you are not reading and writing at the same time, can you explain further?
Actually it does not show any error but does not process the file.
And you are right, the awk script i types was in incorrect format.
But even the corrected one is not processing the file.
I am trying this script in a unix box.
Yes i got the correct output
But no error message is displayed.
It doesnot work at all.
To my understanding, it is reading and writing to the file in the same time.
Is it possible if I can put a time interval, lets say, 2 seconds between Script and mv command?
Actually this is just an example of the input.
Actual input file has about 10,000 records.
If I can put a time interval I beleieve it would resolve my issue.
Yes you can put a time interval between the awk script and the mv command. (Look at the man page for sleep .) Doing so will make your shell script run longer, but will not make any difference in the results on any properly working system.
Unless something else is going on that you have not shown us, sleeping for a microsecond or sleeping for an hour will not make any difference at all.
You have shown us that awk is reading a file and nothing is writing to that file until awk finishes. Then, only after awk finishes, you mv a file. No delay added between the awk and the mv should make any difference at all unless you're running the awk asynchronously (and you have not shown us any script where the awk command is terminated by an ampersand).
Unless something is going on that you have not shown us, adding a sleep will not resolve your issue.