If I have a file that looks like this:
example.png example.jpg example2.jpg example2.png example.swf
example2.swf example3.jpg example4.jpg example3.png example3.swf
and I want to extract the words containing swf for example, the output would look something like this
example.swf
example2.swf
example3.swf
I tried grep -o "swf[^[:space:]]*"
, which just prints a bunch of swf
, and then I tried grep -o '[^ ]*a\.swf[^ ]*'
, which output very few lines containing "swf". Does anyone know what to do?
Best Answer
With GNU grep:
Output:
See: The Stack Overflow Regular Expressions FAQ