awk to replace values in one file using a second reference file
Hi,
I'd be grateful for your help with the following:
I have a file with a single column (file1). Let's say the values are:
I have a second, reference file (ref_file), which is colon-delimited, and is effectively a key. Let's say the values in it are:
I want to use an awk command to scan through file 1, and replace the values with the elements in the reference file, so that the output will be:
(I want values that are already in the correct format in file 1 to be left alone - the '5' in this case).
The script I have tried is:
This doesn't work for some reason, and I don't know why. When I tried the script on a much shortened version of file1, the error message that I get is: awk: can't open file file1.
Any help/suggestions would be much appreciated.
Many thanks.
Last edited by jim mcnamara; 04-21-2016 at 12:02 PM..
Reason: code tags
Basically want to replace any field in input file from the refernce file ...
for example.
clar_2400:3113 in input file will be replaced by clar_2400:3113
Input file field seperator is ","
Field which is not found in reference will stay as it is ...
Input File
... (3 Replies)
Hi,
I have 2 input files:
File 1:
echo Name > create_Name.txt
echo Group /dir/group, Name >> create_Name.txt
File 2:
Name AAA BBB CCC
group A B C
dir A1 B1 C1
................................
Need to replace the contents of File 1 with column 2, 3 & 4 values of File 2... (8 Replies)
Hi,
I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below...
if (start_new_rec=="true"){
exclude_user="false";
user=toupper($6);
match(user, "XXXXX.");
if (RSTART ==2 ) {
... (9 Replies)
Gents,
Can you please help me to solve this case
In my input file I have a values in column 49 which always need to be one, but sometimes the system create a value 2, in this case I need to go to search in the original file and replace the values in the row where the value 2 is and in the... (6 Replies)
Gents,
Please can you help me.
I need to update file1 using file2 values
file1
S 44519.00 49349.00 1V1 0.0 0 0.0 0.0 0.0 0.0289091513
S 44513.00 48581.00 1V1 0.0 0 0.0 0.0 0.0 0.0289094319
S 44511.00 48605.00 1V1 0.0 0 0.0... (1 Reply)
Gents,
Please i need your help.
Using the file2.txt i will like to replace values in file3.txt.
Example in file 2 column 1 is the value to find in file3.txt and replace with value in colunm2 (file2.txt).
Example
file2.txt
21 1209
22 1210file3.txt
SCI TB Timestamp Local : 8/30/17... (2 Replies)