Re: 'grep -o -m' (was Re: Can't mount CD image of Win95 game)
Hi,
The Wanderer wrote:
> With the '-o' option, grep prints only the parts of the line that were
> matched - but the plural here is very relevant. If that guess is
> correct, then the "line" in question has *four* occurrences, so grep
> prints them all - each on a separate line of output.
The man page agrees:
-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.
So -o is probably inapproriate in my pipe.
(It seems to be a development remnant. I got the pipe from a similar one
in an older mail of mine about hacking ISO images as stress test for
GRUB's ISO 9660 reader.)
On the other hand it curbs the length of the output.
David wrote:
> Short demo:
> $ echo 100:CD001 | awk 'BEGIN { FS=":" } /CD001/ { print $1 - 50 }'
> 50
Looks like a good alternative to sed and expr.
(I keep in memory the gesture "awk '{print $1}'" for picking words out of
lines. New stuff does not fit easy into that memory.)
> I only write this because I just magine how poor old 'awk' feels:
> "don't embed me in this pipelines and subshells and unnecessary
> commands, I can do all that stuff myself without any help!!".
My apologies to the venerable Awk Programming Language from an old
procedural programmer.
Have a nice day :)
Thomas
Reply to: