bobo
1
I have the foolowing data file:
File1
<p name="A">5004</p>
<p name="B">5004</p>
<p name="C">5004</p>
<p name="A">15004</p>
<p name="B">15004</p>
<p name="C">15004</p>
In a while loop using sed (100 of line need to be replace), I need the output to File3:
<p name="A">5006</p>
<p name="B">5004</p>
<p name="C">5004</p>
<p name="A">25006</p>
<p name="B">15004</p>
<p name="C">15004</p>
File2 contain:
"A">5004< "A">5006<
"A">15004< "A">15006<
Test Command:
sed -r 's/\"A">5004/\"A">5006/g' File2 <<<<<work
#!/bin/ksh
cat File2 | while read a b
do
sed -r "s/$a/$b/g" File2 > File3
cp File3 File2
done
Please help!:o
You don't need that while loop and it's not clear where you're using file1.
You should be doing something like this
sed -e 's/<stringa>/<stringb>/g' File2 > File3
The following string seems incorrect since you aren't quoting the second "...
's/\"A">5004/\"A">5006/g'
should be
's/\"A\">5004/\"A\">5006/g'
So at a guess you should be doing something like...
sed -e 's/\"A\">5004/\"A\">5006/g' File2 > File3
Hi,
I'm not sure all understand, but try this:
$ cat file1
<p name="A">5004</p>
<p name="B">5004</p>
<p name="C">5004</p>
<p name="A">15004</p>
<p name="B">15004</p>
<p name="C">15004</p>
$ cat file2
"A">5004< "A">5006<
"A">15004< "A">15006<
$ printf "s/%s/%s/g\n" $(<file2) | sed -f - file1
<p name="A">5006</p>
<p name="B">5004</p>
<p name="C">5004</p>
<p name="A">15006</p>
<p name="B">15004</p>
<p name="C">15004</p>
Regards.