Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

awk - Rename output file, after processing, same as input file

$
0
0
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??

This would resolve my issue.


Example:

Code:

awk ' $1=="01" { print $2 $4}' ABC.txt > DEF.txt
mv ABC.txt ABC.orig
mv DEF.txt ABC.txt

ABC.txt
Code:

01  03  03  04
DEF.txt
Code:

01  08  AA FA

Viewing all articles
Browse latest Browse all 16232

Trending Articles