![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can "sed" substitute word on a specific line? | minifish | Shell Programming and Scripting | 2 | 02-14-2008 05:25 PM |
| find a word in a file, and change a word beneath it ?? | vikas027 | Shell Programming and Scripting | 2 | 02-13-2008 04:23 PM |
| In Help, Substitute Text ... | solidhelix08 | Shell Programming and Scripting | 6 | 02-07-2008 05:21 AM |
| Substitute File name | vanand420 | Shell Programming and Scripting | 22 | 03-14-2007 02:40 AM |
| Can a shell script pull the first word (or nth word) off each line of a text file? | tricky | Shell Programming and Scripting | 5 | 08-17-2006 07:29 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
how to substitute more than one word in a text file?
well i have this file here:
<XML> <pregate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <system_c>HPREGATE</system_c> <trans_c>HSPG</trans_c> <trans_dt>20060105161333</trans_dt> <user_id_m></user_id_m> <func_c>C</func_c> </pregate> </XML> i want to substitue pregate with record and also trans_c with trans_b and func_c with func. i use this sed coding here but i can only get the first one substitute which is the pregate to record. the rest of them is not substitute. sed s/pregate/Record/ <pre_xml.txt > pre_xml.txt.tmp sed s/trans_c/trans_b/ <pre_xml.txt >> pre_xml.txt.tmp sed s/func_c/func/ <pre_xml.txt >> pre_xml.txt.tmp im doing this in shell script... hmm..got any idea?? Last edited by forevercalz; 01-12-2006 at 04:45 AM.. |
|
||||
|
$ sed -e 's/pregate/Record/g' -e 's/trans_c/trans_b/g' -e 's/func_c/func/g' test
<XML> <Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <system_c>HPREGATE</system_c> <trans_b>HSPG</trans_b> <trans_dt>20060105161333</trans_dt> <user_id_m></user_id_m> <func>C</func> </Record> </XML> |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|