![]() |
|
|
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 |
| using grep and to remove all word with uppercase | cfg | UNIX for Dummies Questions & Answers | 4 | 10-01-2008 06:56 AM |
| grep for a particular pattern and remove few lines above top and bottom of the patter | fed.linuxgossip | Shell Programming and Scripting | 17 | 07-25-2008 09:29 AM |
| Script to remove log files | kiranherekar | Shell Programming and Scripting | 1 | 03-02-2006 01:24 AM |
| remove files | Nisha | Shell Programming and Scripting | 7 | 06-26-2002 01:04 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
grep, remove and conconate -- xml files
suse linux 10 here.
I have two xml files here and both contain <sf> and </sf> tags in almost beginning and towards the end fo the files. I need to remove the </sf> tag from the first file and the <sf> from the second file and combine both the files into one. I have tried the following script but i am getting a resulting output file which is empty. Please advise. #!/bin/sh # this is myscript.sh if (test -e file1.xml) && (test -e file2.xml) then cat file1.xml|grep -v '</sf>'>billprint.xml cat file2.xml|grep -v '<sf>'>>billprint.xml fi Just FYI: all my xml code is in one line Last edited by basisvasis; 10-22-2008 at 08:40 PM.. |
|
||||
|
If all of the xml is on one line then the grep -v will remove your whole line from the output... since it is all on one line I would use sed to remove the </sf> and <sf> from the files... Code:
$ cat t2.txt <sf>thi si sa test</sf> $ cat t2.txt | sed 's/<\/sf>//g' <sf>thi si sa test $ cat t2.txt | sed 's/<sf>//g' thi si sa test</sf> $ see how that works... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|