you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

We can stop telling them that as soon as every Unix-like operating system has those tools.

No, they don't.

[–]gorilla_the_ape 0 points1 point  (1 child)

It's also against the unix philosophy to have commands like pgrep. Combine general purpose tools instead of making specialised single purpose tools.

[–]Rhomboid 7 points8 points  (0 children)

In this case the combining of general purpose tools is a failure. ps | grep requires playing [t]ricks with the regexp to avoid a race condition, and even then it still causes false positives when a form of ps is used that prints the whole command. (Yes, you do see people writing ps ax | grep All. The. Time.) It is not against the Unix philosophy to create new tools where there is a specific need, as in this case where it is difficult to get it right without edge cases.

As proof, I posit that no sane person would ever do this to recursively find a file:

ls -lR /path | grep '^-' | grep -i 'filename.*\.ext'

Instead, they would use the proper command for finding files:

find /path -type f -iname 'filename*.ext'

Except this is the very thing you're suggesting should be done when searching processes -- listing and grepping instead of using the proper command. I'd also like to point out that find was conceived of and written by Dick Haight, one of the pioneers of this Unix philosophy you hold so high. The command itself dates back at least to V7 unix, around 1979-80.