1

i want remove the tags of following line using sed command in a single command line and i want output to be:- Release Date:September 10,2013

<p><strong>Release date:</strong> September 10, 2013</p>
2
  • .. using sed command in a single command line and i want output to be ... ok, what did you try? Commented Sep 25, 2013 at 7:39
  • Cannot parse html with regex Commented Sep 25, 2013 at 10:57

3 Answers 3

1

The following sed command should remove tags:

sed 's/<[^>]\+>//g' file
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I was using sed twice to remove tags 1) to remove <p>and</p> 2)to remove <strong> and </strong> using e,because i couldn't able to compare more than two pattern at a time:- 1) sed -e 's/<strong>/ /' -e 's/<\/strong>/ /g' grepfile 2)sed -e 's/<p>/ /g' -e 's/<\/p>/ /g' grepfile
It's a regex that matches strings of the form <...> and sed replaces them with nothing. Take a look at a regex tutorial if you cannot understand regexes.
0

The following awk command

awk 'gsub(/ *<[^>]*> */," ")'

2 Comments

gsub replaces all of the longest, leftmost, nonoverlapping matching substrings it can find.The gsub function returns the number of substitutions made. If the variable to be searched and altered, target, is omitted, then the entire input record, $0, is used
it checks for the regular expression and replaces with space,space doesn't effect the output.
0

Try Below

echo "<p><strong>Release date:</strong> September 10, 2013</p>" | sed 's/<[^>]*>//g'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.