Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'And for those trying to learn shell command syntax' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
And for those trying to learn shell command syntax
Authored by: nvdingo on Jan 10, '04 11:00:49AM

That's the vertical bar above the '\' key, not a lowercase L in the hint.

It's called a piped command, where the output of 'ps' with the options 'aux' is piped as the input into the command 'grep' which is trying to match the text Finder.app.

Just trying to help new shell users pick up some important syntax concepts, since most everything done in the shell relies on output from one command being sent directly to another command.

Many sysadmin tasks are completed by single strings of piped commands on a single line.



[ Reply to This | # ]
Why can I find e.g. top, pppd, etc. with this but not Finder, iTunes, etc.?
Authored by: hamarkus on Jan 10, '04 05:38:10PM

Why can I find e.g. top, pppd, etc. but not Finder, iTunes, etc. with this command 'ps aux | grep xxx'? It seems I can only find processes that 'are not owned by me', as in 'needing a sudo to kill them'.

BTW, thanks for the explanation, I've finally understood piping and the grep command.

Markus



[ Reply to This | # ]
Why can I find e.g. top, pppd, etc. with this but not Finder, iTunes, etc.?
Authored by: floop on Jan 10, '04 10:34:33PM

I tried "ps aux | grep Finder" and it did not work for me. What made it work was widening the window, strange. Seems like the line from ps is too long and gets clipped. I find that using ps axc works better to find process numbers.

Also capitalization is important. Use Finder, not finder.



[ Reply to This | # ]
Why can I find e.g. top, pppd, etc. with this but not Finder, iTunes, etc.?
Authored by: aranor on Jan 10, '04 11:47:12PM
If you do ps -auxww | grep -i Finder then it works fine. The 2 w's make it display all data regardless of window size, and the -i to grep makes it case-insensitive. Although, I'm not sure why you'd have a problem with window width when piping - I haven't verified it, but I was under the impression that piped commands ignored the terminal environment since its output wasn't being directed to the terminal.

[ Reply to This | # ]
Yep, window size is the decisive factor
Authored by: hamarkus on Jan 11, '04 06:03:55AM

Either increasing the window size, or using the 'auxww' option makes it display the result of the command. It's funny, I never changed any of the settings of the terminal (10.2.8 installation); when I open a new terminal window it briefly shows: 80x24 and comparing with the screen resolution, the default window should be about 500 pixel wide.



[ Reply to This | # ]
Yep, window size is the decisive factor
Authored by: aranor on Jan 11, '04 09:00:32AM

The 80x24 isn't pixels, it's rows and columns.



[ Reply to This | # ]
Why can I find e.g. top, pppd, etc. with this but not Finder, iTunes, etc.?
Authored by: nvdingo on Jan 11, '04 11:48:24AM

in order for grep to do a case insensitive match, do
`grep -i <pattern>`

do you want grep to show you everything but some pattern?
use -v

case insensitive restrict would be -iv (or -vi)

and of course, you can really narrow down your options by chaining your greps!

You are welcome.



[ Reply to This | # ]
All you Unix/Terminal experts, take a lesson!
Authored by: jiclark on Jan 11, '04 03:29:19PM

If everyone would try to be just a little more explicit with the directions in their comments, as nvdingo added, we newbies and wannabes would be so much better off!

I can't tell you how many times I've wished there was just a little more of an explanation of some terminal command that somebody recommended trying. I realize that it's just second -nature to most of you, but to the rest of us it's a whole new language. A bit of translation would go a *long* ways towards making this site so much better than it already is!!!

Hope I'm not being over-the-top about this. Thanks again, nvdingo, for taking the time to help out those of us less knowledgable about shell command syntax!!

John-o



[ Reply to This | # ]
Anyone asking for someone elses time, take a lesson!
Authored by: drc on Jan 11, '04 11:38:14PM

I suggest the following. The mind of those "experts" is nicely explored at the following webpage:

http://www.catb.org/~esr/faqs/smart-questions.html

For more information try running the " man " command before any cammand i.e. " ps " that you want to know what is does.
Good luck and always read the manual



[ Reply to This | # ]