I did the same question before in other thread, but I want to explain a little better my request.
I am looking for a way how to find and replace a values in two files using a reference a file where are the key to replace.
Basically, I want to keep a copy of the original file and make a new one in order to compare at the end that the change was done in the correct columns whitout change the rest of file..
All files are in the same folder.
Then the files are like this
file name = sw1135g.sps
file name = sw1135g.xps
filename = datatochange.txt ( reference file )
Code:
Then the desired output
file name = sw1135g.sps
Code:
The changed was done in colum 24, value 2 has been replaced by value 1, acoording to file datatochange.txt $5
looking and taking as reference 2657.00 7305.00
file name = sw1135g.xps
Code:
The changed was done in colum 38, value 2 has been replaced by value 1, acoording to file datatochange.txt $5
looking and taking as reference 2657.00 7305.00
In the reference file datatochange.txt, I have wrote the name of the file where the changes need to be done.
the filenames in "datatochange.txt" are like
sw1135g.sps
sw1135g.xps
which are my inputs...
Then, I would like to keep a copy of these files changing the name to
sw1135gOLD.sps
sw1135gOLD.xps
And to get the new ones as: ( where we did the changes --our output files ) should be:
sw1135g.sps
sw1135g.xps
I have many files to change it is only a example for one case. previously I didn't explain that I have many values to change in the same input file,, And looks like using the command get line we can replace only one line of the file ?
I got this from Mr elixier;
With some assumptions:
Code:
Works perfect,, but only for one line...
Please try to help me
Any help on this will be strongly appreciated.
Thanks in advance
Last edited by jiam912; 11-03-2012 at 05:21 PM..
Reason: format of column
please provide a full and representative example of the contend of "datatochange.txt" file
Are the entries of "datatochange.txt" sorted ?
I mean, are all the replacement rules gathered by filename ?
do you only have 2 types of files (*.xps and *.sps)?
---------- Post updated 2012-11-04 at 01:09 AM ---------- Previous update was 2012-11-03 at 09:14 PM ----------
Please avoid duplicate thread.
You could give a try to this quick solution:
1) run the code above
2) then run the generated script "change2run"
This should generate *.new files with all the substitutions done in it.
and "datatochange.txt" can have multiple line with a same filenames, this code should be able to handle it properly
Dear folks
I have a map file of around 54K lines and some of the values in the second column have the same value and I want to find them and delete all of the same values. I looked over duplicate commands but my case is not to keep one of the duplicate values. I want to remove all of the same... (4 Replies)
Hi everyone,
This is an exemple of inpout.txt file (a "," delimited text file which can be open as csv file):
ID, Code, Value, Store SP|01, AABBCDE, 15, 3 SP|01, AABBCDE, 14, 2 SP|01, AABBCDF, 13, 2 SP|01, AABBCDE, 16, 3 SP|02, AABBCED, 15, 2 SP|01, AABBCDF, 12, 3 SP|01, AABBCDD,... (1 Reply)
Hello Guys.
I have a very big file where I need to change some values according a list on other file.
The following file is were I have the values to be changed.
The field where I need to replace the values is
File_Nb : File1.txt
Obs_Report_Result :
# ===== (5)... (19 Replies)
Hi All,
i have a file like
col1 col2 col3
13 24 NA
12 13 14
11 12 13
14 22 NA
18 26 NA
in this file if i found "NA" other values in the line are also replace by NA
Could you help me! (7 Replies)
Hi,
I need help to find values between two different fields based on $6 (NUM) AND $1 (CD), within the same ID. The result should show the values between the NUMs which will be extracted from within $3 and $2 in data.txt file below.
data.txt
ex 139 142 Sc_1000004 ID 4
CD ... (2 Replies)
I have a file in which I want to do multiple find and replace of strings. For a single replace I can implement:
sed -i 's/old/new/' <input_file>
I have a second file that contains the old and the new values like the arbitrary example below:
old new
xyz pqr
ab 756
rst pqr... (3 Replies)
I have file which as 12 columns and values like this
1,2,3,4,5
a,b,c,d,e
b,c,a,e,f
a,b,e,a,h
if you see the first column has duplicate values, I need to identify (print it to console) the duplicate value (which is 'a') and also remove duplicate values like below. I could be in two... (5 Replies)