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


Click here to return to the 'making pidof case insensitive?' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
making pidof case insensitive?
Authored by: madgnome on Jun 20, '03 08:54:20AM

Hi, not to appear too lazy or stupid, but is there a way to make pidof case insensitive? I hate having to remember if something like itunes is iTunes or Itunes or iTuNeS or whatever.

I've always been a 'ps | grep -i' kind of person.

---
--Jeff



[ Reply to This | # ]
making pidof case insensitive?
Authored by: adamjacobmuller on Jun 21, '03 06:29:23PM

#!/bin/sh
ps axc|tr '[:upper:]' '[:lower:]'|awk "{if (\$5==\"`echo $1|\
tr '[:upper:]' '[:lower:]'`\") print \$1}"|tr '\n' ' '
echo


this makes all the output of ps axc lowercase then makes all your input lowercase so that it always matches regardless of case, this can be good this can be bad... i wonder if this is how the real pidof works? <<ssh's to his linux box to check>>
it's not, so it's probably not the best idea to do this, then again in most enviroments it would be unusual to have an uppercase letter... anywhere in the filename of a program.... so perhaps this isnt so bad.... it could just lead to false-positives.



[ Reply to This | # ]
making pidof case insensitive?
Authored by: dpwk on Jun 25, '03 06:16:23PM

My solution, short and reasonably sweet (I call it pidf):


#!/bin/sh
ps axc | grep -i $1 | awk "{ print \$1}";



[ Reply to This | # ]