Results vary. I used a pretty rough but effective regex. Did you use an extended regex without telling sed?:
PS: For variant element regex, the second test, element not closed, s/b a back referencer, \(whatever\) I opened with, have I closed with that = \1 ?:
Last edited by DGPickett; 01-11-2011 at 05:15 PM..
i ran it like you have specified the output hasn't changed at all.. (substituted MsgBlk with my regex)
is there a way with sed to removed more than one set of lines in one line?
so i mean
sed ${firstElem},${lastIndex}d web.xml > web1.xml
this will delete lines between ${firstElem},${lastIndex}
i want in the same line to do somethinkg like this (doesn't work so far)
sed ${firstElem},${lastIndex}d ; ${secondElem},${lastIndex1}d web.xml > web1.xml
at the same time delete lines between ${firstElem},${lastIndex} and ${secondElem},${lastIndex1}d
if i don't do this in one line.. indexes for the second set change.. and i need to grep for them again.. so it would be really good if i could delete the two sets simulatiously..
thanks a lot
---------- Post updated at 06:29 PM ---------- Previous update was at 06:28 PM ----------
Quote:
Originally Posted by DGPickett
Results vary. I used a pretty rough but effective regex. Did you use an extended regex without telling sed?:
PS: For variant element regex, the second test, element not closed, s/b a back referencer, \(whatever\) I opened with, have I closed with that = \1 ?:
trying a different way.. now..
is there a way with sed to removed more than one set of lines in one line?
so i mean
sed ${firstElem},${lastIndex}d web.xml > web1.xml
this will delete lines between ${firstElem},${lastIndex}
i want in the same line to do somethinkg like this (doesn't work so far)
sed ${firstElem},${lastIndex}d ; ${secondElem},${lastIndex1}d web.xml > web1.xml
at the same time delete lines between ${firstElem},${lastIndex} and ${secondElem},${lastIndex1}d
if i don't do this in one line.. indexes for the second set change.. and i need to grep for them again.. so it would be really good if i could delete the two sets simulatiously..
Well, sed will happily delete ranges with "/regex1/,/regex2/d", and you can do that as many times as you want (as long as one does not start within another).
Your xml is pretty well behaved, but I often normalize it so every element starts at the beginning of a line. That simplified subsequent parsing, so you do not need to worry about one line elements except like <xxx yyy="zzz" www="xxx" />. You could expand that, so it is entirely simply normal.
I often pile sed on sed in a pipeline. The sort of sed that loops and does N does not mix easily with those that do simple line filtering, so why not, pipes are free. You can even embed each sed command in an executable script file that begins in the line "#!/usr/bin/sed -f" (your path may vary) and execute the scripts.
if i don't do this in one line.. indexes for the second set change.. and i need to grep for them again.. so it would be really good if i could delete the two sets simulatiously..
thanks a lot
If you use regex not line #, then line numbering is not an issue. Consider doing it like "diff -e" output: put the changes in reverse line number order.
sed numbers lines at input, so the numbers do not change on one pass, in any case.
I am using : << cut / cut to comment out block of code.
Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines.
The "warning " is at last line of script.
done < results
169 echo "END read all positioning parameters"
170... (8 Replies)
Hello!
I'd like to modify custom values in a XML config file between comment tags using bash script.
<feature>
<keyboardshortcut>C-m</keyboardshortcut>
<option1>disabled</option2>
<option2>enabled</option2>
</feature>
<!-- bash script features START -->
<feature>
... (2 Replies)
(1) Yes but how is this block different from the other 24? You will need this information in order to identify and replace this block correctly (out of the 25).
Ans: The 1st line and last line of this block are unique from other block.
The 1st line is “rem Subset Rows (&&tempName.*) and
The... (1 Reply)
hi ,
i m having a html file and this file looks like this
<ssl>
<name>PIA</name>
<enabled>true</enabled>
<listen-port>39370</listen-port>
</ssl>
<log>
<name>PIA</name>
</log>
<execute-queue>
<name>weblogic.kernel.Default</name>
... (7 Replies)
Hi All,
I have been working on something that doesn't seem to have a clear regex solution and I just wanted to run it by everyone to see if I could get some insight into the method of solving this problem.
I have a flat text file that contains billing records for users, however the records... (5 Replies)
I'm trying to write a script to help automate some VERY tedious manual tasks.
I have groups of fairly large XML files (~3mb+) that I need to edit.
I need to look through the files and parse the XML looking for a certain flag contained in a field. If I find this flag (an integer value) I need... (4 Replies)
Hi,
I would like to get rid of all comment in an xml file by grep or sed command:
The content seem like this:
<!-- ab cd
ef gh
ij kl -->
Anyone can help?
Thanks and Regards (3 Replies)
Hi All,
I am looking for a awk/shell which can find an element named REFERENCE in a XML file and check whether it is empty or not.
If there is no value in the REFERENCE element then correspondingly move the file to some other folder.
The Unix server is AIX version 4.
Any inputs... (9 Replies)
I have a file shows as below. I would like to put # before CCCC. so how to do in Solaris. Here sed doesnot support -i
AAAA
BBBB
CCCCC
DDDDD
EEEEE
FFFFFF (1 Reply)