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


 
Thread Tools Search this Thread
# 8  
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.
# 9  
So it is just
Code:
mv DEF.txt ABC.txt

that is giving you trouble?

In post #1 you mentioned an error. What is the exact error message..
# 10  
Since i dont see any error message ,

I cant tell if it is coming from thie 2nd or the 1st command but to my understanding, it is coming from mv DEF.txt ABC.txt

I misused the word error. Actually there is no error message.
I am going to update my question.
# 11  
Quote:
Originally Posted by High-T
.
.
.
Code:
awk ' $1=="01" { print $2 $4}' ABC.txt > DEF.txt
mv ABC.txt ABC.orig
mv DEF.txt ABC.txt

Looking at your post #1, what keeps you from
Code:
mv ABC.txt ABC.orig
awk ' $1=="01" { print $2 $4}' ABC.orig > ABC.txt

?
# 12  
Is it possible if I can put a time interval between the awk script and mv commands??

This would resolve my issue.
# 13  
Quote:
Originally Posted by High-T
Is it possible if I can put a time interval between the awk script and mv commands??

This 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.
This User Gave Thanks to Don Cragun For This Post:
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Science: Mathematics
Difficulty: Medium
The set of all algebraic numbers is countable.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to reformat output if input file is empty, but not if file has data in it

The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format: input chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18 chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies

2. UNIX for Dummies Questions & Answers

Redirect output to the same input file in awk

Hi, I want to compare a value from test file and redirect the o/p value to the same file input file 250 32000 32 128 Below is my code awk '{ if ($1 < "300") print $1 > /tmp/test}' test want to compare 250 < 300 then print 300 to the same place below is the... (24 Replies)
Discussion started by: stew
24 Replies

3. Programming

awk processing / Shell Script Processing to remove columns text file

Hello, I extracted a list of files in a directory with the command ls . However this is not my computer, so the ls functionality has been revamped so that it gives the filesizes in front like this : This is the output of ls command : I stored the output in a file filelist 1.1M... (5 Replies)
Discussion started by: ajayram
5 Replies

4. Shell Programming and Scripting

Recursive file processing from a path and printing output in a file

Hi All, The script below read the path and searches for the directories/subdirectories and for the files. If files are found in the sub directories then read the content of the all files and put the content in csv(comma delimted) format and the call the write to xml function to write the std... (1 Reply)
Discussion started by: Optimus81
1 Replies

5. Shell Programming and Scripting

processing an input file and then the output file

Hi. I am new to scripting and could really do with some advice on the best way to put a script together. Here is the scenario I am working to; - i will get files via ftp to a tmp directory on the server - all files will have a unique file name but with the same extension (.USM) - for each... (5 Replies)
Discussion started by: yabai
5 Replies

6. Shell Programming and Scripting

AWK Script to convert input file(s) to output file

Hi All, I am hoping someone can help me with some scripting I need to complete using AWK. I'm trying to process multiple fixed files to generate one concatenated fixed file in a standard format. The Input file is:- aaaa bbbbb ccccc 1 xxxx aaa bbb aaaa bbbbb ccccc 2 abcd aaa CCC... (9 Replies)
Discussion started by: jason_v_brown
9 Replies

7. Shell Programming and Scripting

Dynamic output file generation using a input text file with predefined output format

Hi, I have two files , one file with data file with attributes that need to be sent to another file to generate a predefined format. Example: File.txt AP|{SSHA}VEEg42CNCghUnGhCVg== APVG3|{SSHA}XK|"password" AP3|{SSHA}XK|"This is test" .... etc --------- test.sh has... (1 Reply)
Discussion started by: hudson03051nh
1 Replies

8. Shell Programming and Scripting

Pass input and output file as parameter to awk script

Hi, i am new to awk. I am using csv2pipe script(shown below) BEGIN { FS=SUBSEP; OFS="|" } { result = setcsv($0, ",") print } # setcsv(str, sep) - parse CSV (MS specification) input # str, the string to be parsed. (Most likely $0.) # sep, the separator between the values. # #... (6 Replies)
Discussion started by: bhaskarjha178
6 Replies

9. Shell Programming and Scripting

awk should output if one input file doesnt have matching key

nawk -F, 'FNR==NR{a= $3 ;next} $2 in a{print $1, 'Person',$2, a}' OFS=, filea fileb Input filea Input fileb output i am getting : (2 Replies)
Discussion started by: pinnacle
2 Replies

10. Shell Programming and Scripting

Writing output into different files while processing file using AWK

Hi, I am trying to do the following using AWK program. 1. Read the input data file 2. Parse the record and see if it contains errors 3. If the record contains errors, then write it into Reject file, else, write into usual output file or display it on the screen Here is what I have done -... (6 Replies)
Discussion started by: vidyak
6 Replies

Featured Tech Videos