How could you match all characters until first occurrence of a particular sequence of characters with
grep? I'm looking for a way to accomplish this task in Linux environment and since I might missing some crucial point of
grep functionality, ideas with solutions with
sed are also welcome.
The problem also involves matching separately all occurrences of the pattern in a single line.
To better understand the situation, let's say we have a command
echo "word word" | grep -o 'w.*rd'
It looks like it matches up until last occurrence of the sequence
rd, so when we run this we get:
What I'm actually looking for is: