I'm using this regex (?<=\[')[^,]*
on a file containing the following line disk = ['OVS/sdasd/asdasd/asdasd/something.img, w']
I want that to return OVS/sdasd/asdasd/asdasd/something.img
How do I use grep
to make it work?
I've tried grep -P "(?<=\[')[^,]*"
but it returns the whole line.
Best Answer
Add the
-o
switch so thatgrep
only returns what matches the pattern you're grepping for: