is it possible to reverse the output of grep -o
What do you mean?
" Do not grep <pattern> " ? Which would be a grep -v ...
I don't think so.
It's an easy one for sed:
sed "s/something//"
what is grep -o? , maybe you're looking for grep -v
-o extracts only the matched text. i.e.
$ echo extract this | grep -o this
this
a file containing
https://www.amazon.com
Help.com
https://www.google.com
http///www.bbc.com
grep -o 'https://' filename
....... print non matching part of output
$ sed "s#^https://##" file
www.amazon.com
Help.com
www.google.com
http://www.bbc.com
Or
$ sed "s#^[^/]*//##" file
www.amazon.com
Help.com
www.google.com
www.bbc.com
1 Like
sorry i've framed my question incorrectly.
I need to grep a file for a pattern and output the non matching part of the line
Then post a sample of the input and a sample of the expected output (using code tags, please).
This may be it :
awk '/https:\/\// {gsub (/https:\/\//, ""); print}' file
www.amazon.com
www.google.com
1 Like