![]() |
|
|
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 |
| mget * (obtein files from current directory but not the files form sub-directories) | Peter321 | Shell Programming and Scripting | 0 | 03-12-2009 11:59 AM |
| Merge files of differrent size with one field common in both files using awk | shashi1982 | Shell Programming and Scripting | 2 | 03-03-2009 07:12 AM |
| I need a script to find socials in files and output a list of those files | NewSolarisAdmin | Shell Programming and Scripting | 1 | 02-19-2009 01:01 PM |
| Find duplicates from multuple files with 2 diff types of files | ricky007 | Shell Programming and Scripting | 2 | 03-04-2008 01:46 PM |
| text files, ASCII files, binary files and ftp transfers | Perderabo | Answers to Frequently Asked Questions | 0 | 04-08-2004 05:25 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
sed has zeored my files. Help me with sed please
i made a script to update a lot of xml files. to save me some time. Ran it and it replaced all the the files with a 0kb file. The problem i was having is that I am using sed to change xml node <doc_root>. The problem with this is it has a / in the closing xml tag and the stuff inside will also have a bunch of / because it is a file path. so i am using sed and was hoping this would work:
Code:
sed 's/<doc_root><\/doc_root>/<doc_root>\/'$i'\/web<\/doc_root>/g' $my_file > $my_file Or if its the regex can someone help with that Here is the search string Code:
<doc_root></doc_root> Code:
<doc_root>/domain.co.uk/web</doc_root> Please help before my boss gets angry with me ![]() |
|
||||
|
Quote:
I will look into the function of the sed but you are redirecting the output to the same file name, you shud never do that. that is why u have 0kb file. redirect it to a temp file verify the result mv tempfile filename cheers, Devaraj Takhellambam |
|
||||
|
cool lots of variations. This also works
Code:
sed 's/<doc_root><\/doc_root>/<doc_root>\/'$i'\/web<\/doc_root>/g' $my_file > "tmp/"$i".xml" mv "tmp/"$i".xml" $my_file Also you need to double quote "$i" in case a file name has embedded quotes: Code:
sed 's/<doc_root><\/doc_root>/<doc_root>\/'"$i"'\/web<\/doc_root>/g' $my_file > "tmp/$i.xml" mv "tmp/$i.xml" "$my_file" |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|