File this under #shell #functions I should have written years ago:

function grepc { #Do a grep -c, but skipping files with no results grep -c "$@" |grep -v ':0$' }

#unix #UnixShell #ShellScripting #bash #ksh

@rl_dane

Oh, didn't know about -c. I usually just pipe to wc -l I guess.

@amin

-c, -l, -h, -H, and -q are my favorite #grep flags. :D

Huh, that almost became a [Marcel Duchamp] reference. πŸ˜…

Marcel Duchamp - Wikipedia

@rl_dane

I just use -v and -E

@amin @rl_dane you guys use flags?... :p

@sotolf @rl_dane

Not usually, but -v is useful to select anything that doesn't match, and -E lets me use extended Regex, which is occasionally useful.

@amin @rl_dane Yeah, it was mostly a joke, I do use -v at some times, but I usually have enough of an idea of what I look for, and am not really doing much complex scripting, so I don't usually need the complex stuff that grep can do :)

@sotolf @amin

grep -vxf file2 file1 is very useful for displaying lines that are in file1 but not file2, like a position/sort-independent diff

-x matches whole lines, and of course -f reads regexps from a file.

@rl_dane @sotolf

I use comm for comparing files.

@amin @sotolf

There are so many little unix utilities I keep forgetting about, like comm. XD

I have used that before. It's nice.

@rl_dane @sotolf

I need to finish my "all the coreutils" blog post…