awk '! /something/'
Doesn't it reproduce the same behaviour as the following? grep -v 'something'51–60 of 136 posts
awk '! /something/'
Doesn't it reproduce the same behaviour as the following? grep -v 'something'AWK is the general-purpose programmatic filter and reporting tool in the Unix pipeline. Sed, grep and cut are specializations for specific use cases whose implementations might have better performance. Perl and Python are probably too general-purpose for writing compact one-liners in a pipeline.
Earlier quoted context omitted.
Serious question: what would be a better way to do this?
As per other users, you can use pkill but it's not entirely portable in meaning between OSs. This software had to run on just about every possible Unix out there. Solaris, HP-UX, AIX, many others ... My main point is that using perl and grep, (multiple thereof!) is nuts when you can do it all in perl. Also crazy was using -ef (all processes) when the process of interest was using a known user. So ps -u would be more…
Earlier quoted context omitted.
That's what I was referencing when I said > Pulling out a field from a line is what most people use awk for, but it's honestly the least interesting part of awk. In fact, if cut supported regular expressions for specifying the field and record separators people wouldn't be using awk for that purpose (because that's all that $n does). There's nothing magical about awk's default FS. It's literally just /\s+/. If cut's…
The default FS throws away leading blanks, though, which doesn't happen if you set it explicitly to \s+, so a tiny little bit of magic does go on after all.
some-cmd | sed -E '{ s/^\s+//g ; s/\s+/ /g }' | cut -f$nThe author mentions that using awk instead of grep -v is not a good idea, what about: awk '! /something/' Doesn't it reproduce the same behaviour as the following? grep -v 'something'
My favourite bad example of using grep was from a big enterprise software vendor to kill one of their processes. It looked something like ps -ef| grep SomeDaemon | grep -v grep | grep -v perl | perl -e ' '
Serious question: what would be a better way to do this?
Earlier quoted context omitted.
grep -v grep.. I wish I could admit to using this less often than I do; but it's always manual not automated. At some point I'll figure out a better alternative than this or pgrep which often misses processes.
Just do 'grep [S]omeDaemon', and you won't see your grep line.