Thanks Frank. It removes contents in all the occurrence of <script> and </script> tag. It removes the content in the complete line where the above tags are present.
Could you please help me to remove the content which are between those tags instead of removing everything in a line.
Example:
*Below is the output that i get when i execute your command
input file content:
client side<script>java script</script>java scripting is.......
server side<scipt>classic asp</script>ASP is a microsoft technology.......
satheesh here
output:
satheesh here
But i want the output as:
client side java scripting is.......
server side ASP is a microsoft technology.......
---------- Post updated at 09:28 AM ---------- Previous update was at 09:24 AM ----------
You are correct jville. Thats what i need exactly.
Frank it works fine for the first line. But when it comes to the next line of input it does the same error. It removes the complete line instead of just removing the content between the <script> </script> tag.
This time i get the output as
client side java scripting is.......
satheesh here
instead of
client side java scripting is.......
server side ASP is a microsoft technology.......
satheesh here
Second line of input has been deleted as the whole. It seems that the conditional deletion works only for first occurrence.
#n
:top
/<script>/ {
# Change the first <script> in the line to \n.
# We can be certain that there will not be a newline in the
# initial pattern space, so this is unambiguous.
s//\
/
# If the closing </script> is on the same line, change it also
# to \n and delete everything in between, newlines inclusive.
# If the result in an empty line, print nothing.
/<\/script>/ {
s//\
/
s/\n.*\n//
b empty?
}
# The </script> element is not on the same line as its <script>.
# Before moving on in search of it, delete from the newline to the
# end of line. Print only if the line is not empty.
s/\n.*//
/./p
# Discard lines until closing </script> is found.
:next
n
/<\/script>/! b next
# Change </script> to \n and delete preceding text.
s//\
/
s/.*\n//
:empty?
# If the line has been left empty, do not print a blank line.
/./!d
# In case there's another <script> element later in the line.
b top
}
p
Descriptinator Test run:
$ sed -f descriptinator.sed testdata
12345
23456
34567
45678
56789
Thank you Alister. It is working great. Most importantly it works for most of the cases especially when the starting and the ending tag are in same line.