sed to modify the file in place:
sed -i '/^\(report\|-t\(h\|o\)\)/!d' your_file
sed to delete all lines not matching the pattern. The pattern itself is
^ (start of line), followed by either
-t followed by either
You should note that this is not actual in-place modification:
sed creates a temporary backup copy and overwrites the original file with it.
If you want
sed to keep a backup copy of the original file (which might be a good idea if the file contains critical data), give the
-i switch an extension to create a backup file:
sed -i'.bak' -e '/^\(report\|-t\(h\|o\)\)/!d' your_file
your_file and create a backup of the original called
A side note
Please don't misconstrue my intentions or take offence at this, but I've noticed that you have many similar regex/text-processing related questions. I advise you to start learning
grep on your own to help speed up your productivity. Again, don't get me wrong, I'm all too happy to help (as are most people around here); it's just that I think that you stand to benefit hugely from picking up these tools for your daily use.
Just to prove how helpful people are around here, consider @slm's suggestion in the comments below and feel free to drop by this chatroom any time for questions.