user2671513
user2671513

Reputation:

Shell, bash : grep the html tag in multiple lines

Shell, bash : grep the html tag in multiple lines

How do I grep from tr to /td in input.txt?

   <tr>
   <td>Answer</td>

My code is

 grep -o "<tr>.*</td>" input.txt > output.txt

But it returns nothing..

Upvotes: 1

Views: 1599

Answers (1)

iruvar
iruvar

Reputation: 23364

You'd be better off using a HTML parser, but for simple needs a range-based solution may work

awk '/<tr>/,/<\/td\>/' input.txt

Upvotes: 1

Related Questions