I am a newbie in shell scripting and I'm trying to write a script which reads lines from a file, searching some of this lines to change a specified number. I want to replace the line for another in the file.
I have to replace multiples lines, so I have a for. Now I am trying with two lines but my code only changes the last. I have something like that:
(Edited)
I have realised that my code does not work when the line to change has this character: * So a line like this: "* NULL *" will not be replaced and this sentence: sed "s/$line/$newline/" auxfile >newfile won't work.
There is any way to escape this characters?
(/Edited)
Can anybody help me? I don't know why this does not work.
Thanks!
---------- Post updated at 11:42 AM ---------- Previous update was at 10:00 AM ----------
Hi again!
Finally I have decided to copy line per line in another file, changing the lines I want and write them onto the new file using echo...
But if anybody can explain me why a string with '*' won't work with sed I will be glad to learn it!!
I have a file lake this
cat ex1.txt
</DISCOUNTS>
<B2B_SPECIFICATION elem="0">
<B2B_SPECIFICATION elem="0">
<DESCR>Netti 2 </DESCR>
<NUMBER>D02021507505</NUMBER>
</B2B_SPECIFICATION>
<B2B_SPECIFICATION elem="1">
<DESCR>Puhepaketti</DESCR>... (2 Replies)
Replace first 3 characters in a unix file (say replace "A&B" with "C&D") in all lines of the file. Need a sed or awk script to do this. Kindly help!
-Kumar (4 Replies)
Hello,
I have 8 lines containing these unique words in both files
645147468537
673962863160
673962864957
691717701950
707917019907
790085591726
792975507744
852174812753
file.dat.orig (has 1000 lines) and file.dat(has only 8 lines)
I want to replace those lines in file.dat.orig by... (1 Reply)
Hi all,
I have two parameter blocks in a configuration file, file1.conf.
First parameter block starts with PWAT-PARM1 and
ends with END PWAT-PARM1.
Second parameter block starts with PWAT-PARM2 and
ends with END PWAT-PARM2 (please see below in file1.conf).
file1.conf is fixed width... (8 Replies)
I've got a file full of numbers, example:
cat test.file
60835287
0
51758036
40242437
0
32737144
0
24179513
0
4131489957
I want to replace those numbers (4 Replies)
Hello
I am a beginner in shell script.
I was trying to find a way to replace multiple lines of a file with different set of multiple line.
sed -n '/begin/,/end/p' < sample1.txt >test.txt
UNEDITED=`cat test.txt`
vi test.txt
EDITED=`cat test.txt`... (2 Replies)
Hi all,
I am new to UNIX, so sorry if my question seem stupid to u.
well i want to replace the first character of first 30 lines of a file, only if the first character is h.
and
in anothe script i want to replace a particular string/character say hello/h of a file.Condition: It should... (1 Reply)