![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with looping | finalight | Shell Programming and Scripting | 2 | 05-23-2008 05:35 AM |
| help on looping using if/for or while | sam4now | Shell Programming and Scripting | 1 | 04-24-2008 10:33 AM |
| looping | ishir | Shell Programming and Scripting | 4 | 09-17-2005 03:52 AM |
| looping and awk/sed help | Zelp | Shell Programming and Scripting | 13 | 06-29-2005 01:13 AM |
| Looping in awk | keelba | UNIX for Advanced & Expert Users | 3 | 05-31-2002 01:04 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Looping and using Sed
Hi guys
I having som problem trying to use sed to get a file and insert inside another one. I'll try to explain better. I have a base.txt and using sed(having a array variables) I'm chaging some strings inside this file and saving as base1.txt. until here okay. Then, I have to get this base1.txt and insert it inside another file called script.txt. Well, If I didn't have any looping so far so good. Then, when the script restart, it has to change the base file again, with a different variable(until here okay), and then get this base1.txt again and insert at the same old file script.txt. The problem is, Sed cleans out the file when I overwrite it. I tried to rename files, but I just can't reach the logic of doing this... Any suggestion would be a lot appreciatted. Thank you in advance. Rodrigo Guimaraes |
| Forum Sponsor | ||
|
|
|
|||
|
Hi Franklin,
Thanks for your attention. this is the code # Changing the Strings sed -e s/INICIO/$startframe/g \ -e s/FIM/$endframe/g \ -e s/TEMPOINICIAL/$TEMPO1/g \ -e s/TEMPOFINAL/$TEMPO2/g \ -e s/epXXX/ep${EP}/g \ -e s/scXXX/sc${SC}/g \ -e s/shXXX/sh${SH}/g \ -e s/NAME/${i}/g < ${tmpFolder}filesin_line.txt > ${tmpFolder}filesin_line1.txt sed '$ r' '${tmpFolder}filesin_line1.txt'' < ${tmpFolder}filesin_line1.txt > ${tmpFolder}filesin_lineNEW.txt rm ${tmpFolder}filesin_line1.txt done exit ------- filesin_line.txt ( this is the first file that has to be inserted into the next one (filesin_lineNEW.txt )) I don't know if I'm explaining right. But when the looping happens, sed can't overwrite the file (filesin_lineNEW.txt) and I don't know what do it to make sed add the previous modified file. Please let me know if explanining well...sorry. Thanks |
|
|||
|
Hi Franklin
I did a small test here outside the script with your line using cat and it seems it worked. Wow! That's great! Sometimes are so many commands that I get confused what to use... Thanks a lot for your help and your attention Franklin. |
|||
| Google UNIX.COM |