0

I can grep two strings 'ion' and 'spin' from a file but would also like to either:

  • grep only if both strings exist
  • or only grep if the 2nd string is in the next line

grep -w 'ion\|spin' filename

I want to grep from a file which contains random strings like this:

  <set comment="ion 3">
   <set comment="spin 1">

but only if the word "spin" occurs in the next line.

Jenni
  • 23
  • 3
  • [Don't Parse XML/HTML With Regex.](https://stackoverflow.com/a/1732454/3776858) I suggest to use an XML/HTML parser (xmlstarlet, xmllint ...). – Cyrus May 15 '20 at 16:31
  • I hope you meant to make it so that the upper code is also in a grey box? – Jenni May 15 '20 at 16:40

0 Answers0