![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 07:24 AM |
| Search and Replace in Ksh | DeepakXavier | Shell Programming and Scripting | 9 | 05-28-2007 05:11 AM |
| how to search for a str and replace it.. | sekar sundaram | Shell Programming and Scripting | 6 | 12-29-2005 03:11 PM |
| Search and replace sed or tr | bridgeje | Shell Programming and Scripting | 6 | 10-28-2003 04:54 AM |
| search and Replace | mukeshannamalai | UNIX for Advanced & Expert Users | 4 | 09-14-2001 03:21 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
sed search and replace
Hello Folks,
Anyone know how I can replace this line in file.xml <oacore_nprocs oa_var="s_oacore_nprocs">8</oacore_nprocs> with this line <oacore_nprocs oa_var="s_oacore_nprocs">1</oacore_nprocs> using sed or awk ? Thanks for your time. Cheers, Dave |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
sed -e "s/\(<oacore_nprocs [^>]*>\)[^<]*\(<.*\)/\1SOME-TEXT-TO-GO-IN\2/g" |
|
#3
|
|||
|
|||
|
Hi thanks for the reply.
I'm not sure I understand the command, I just need to replace the 8 with the 1 on that particular line in file.xml Will this do that ? I cant see how it will. Thanks |
|
#4
|
|||
|
|||
|
as simple as this
sed -e 's/ptrn/newptrn/g' file |
|
#5
|
||||
|
||||
|
Quote:
Replace SOME-TEXT-TO-GO-IN with 1 |
|
#6
|
|||
|
|||
|
tried both suggestions, neither worked.
sed -e "your_command" file.xml just cats the file and does nothing |
|
#7
|
||||
|
||||
|
Quote:
Something like Code:
sed -e "your_command" file.xml > file.xml.new mv file.xml.new file.xml |
||||
| Google The UNIX and Linux Forums |