grep
Now, for your assignment, write a bash one liner or short script that finds and kills any process associated with Firefox.
P.O. Box 98199
Washington, DC 20090-8199
800-647-5463
Lat/Lon: 38.90531943278526, -77.0376992225647
grep
Now, for your assignment, write a bash one liner or short script that finds and kills any process associated with Firefox.
This lives in ~/scripts and there’s a Gnome launcher in the top panel that activates it. I use it (too frequently) when ‘dobe Flash drives Firefox insane.
kill -HUP `ps -aef | grep -i firefox | awk ‘{print $2}’`
just curious, why use grep then awk, rather than just the awk filter?
(this on mac terminal so ps has no ‘f’ arg)
kill -9 `ps acx | awk ‘/Firefox/ {print $1}’ `
though I suppose if the capital were the issue:
kill -9 `ps acx | awk ‘/irefox/ {print $1}’ ` or
kill -9 `ps acx | awk ‘/[Ff]irefox/ {print $1}’ `
The process should always be all lower case.
The auk filter is good. But, using grep in line after ps is one way of compartmentalizing the flow. So it could depend on what the larger scale objective is.
What, is “killall firefox” insufficient? I suppose if you’re exercising the reader, or if /usr/bin/killall doesn’t exist on your distro…
Actually, I retract my previous comment, on the grounds that people should learn to do things the hard way first, and that I couldn’t do my job day to day without grep and awk. I even installed Windows versions of those two commands on my DC.
killall firefox-bin
I’ll get marked down when I’m graded, because it doesn’t do exactly what the assignment asked for. For one thing, although it will kill the Firefox main process (which is called firefox-bin in Debian) and its children, any orphans will get left behind. But there are seldom, if ever orphans, so that hasn’t been a problem.
could you define what you mean by “compartmentalizing the flow?”
(btw, for what it’s worth, on mac os, GUI applications tend to be capitalized on mac os. (i.e. safari is “Safari”) or at least displayed as the finder knows them.)
I mean when you are writing code and you have a series of steps some of which you change. I do this all the time. This is why I use cat to feed a stream to a process via pipe. All the other Linux people hate me but I don’t care.
This discussion does not apply to Macs. This discussion is about when something goes wrong. I’m told that this does not happen on Macs. Is that not the case? Please, no, don’t let i be so! Don’t let it be so!
(OK, sorry, I’m in a nasty mood this afternoon. Don’t be the guy in front of me on the highway exit who decides to clean out his freakin’ glove compartment instead of drive!!!! Or whatever.)
pkill firefox
Or if using grep is really mandatory:
ps acx|grep firefox|cut -f1 -d” “|xargs kill
Good point. Why use auk when you can use cut????????
Click here to visit my page for the novel Sungudogo, which is now available for the Kindle
I and the BIRD … not just a Web Carnival any more
Cats, Carnivores, and various Mammals
Gun Control
Birds and Bird Books