root@shell02:~# for x in `ptree | awk '{print $1}'`; do pfiles $x | grep -w ${PORT} > /dev/null 2>&1; if [ x"$?" == "x0" ]; then ps -ef | grep $x | grep -v grep; fi; done 2> /dev/null root 5386 5331 0 Oct 06 ? 1:29 /lib/svc/bin/svc.configd root 6211 6209 0 Oct 06 ? 0:02 /usr/lib/autofs/automountd root 17437 6425 0 09:02:56 ? 0:00 /usr/lib/ssh/sshd root 6425 5331 0 Nov 10 ? 18:54 /usr/lib/ssh/sshd root 17437 6425 0 09:02:56 ? 0:00 /usr/lib/ssh/sshd bob 17438 17437 0 09:02:56 ? 0:00 /usr/lib/ssh/sshd bob 17438 17437 0 09:02:56 ? 0:00 /usr/lib/ssh/sshd bob 17441 17438 0 09:02:57 pts/1 0:00 -sh daemon 12227 5331 0 Dec 03 ? 0:00 /usr/lib/nfs/statd daemon 12232 5331 0 Dec 03 ? 0:00 /usr/lib/nfs/lockd root@shell02:~#
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: