I am trying to find a regular expression which would allow me to delete entire content of a file if a particular string matches.
As an example, my file contents are:
This is the first line
Here is password=SECRET second line
Here is third line
I am doing search for string with pattern password= and when that match happens, ALL lines should be removed from the above file.
Below command does remove the entire line matching the pattern but I can't figure out a regular expression for removing the entire content:
cat test.txt | sed 's|^.*password=.*||'
I understand sed works line by line and unless I use additional options in sed, I probably do not have a way to delete the entire content.
The reason I am only interested in regular expression is that I am using another tool which uses regular expression as an input to perform transformations. I use sed here as an example to illustrate what I understand so far.