|
|
A perl version
Adam's solution is more elegant, and more succinct than mine. But I'm more of a perl hacker, than a shell programmer. If you want a version that will match based on a regular expression, instead of an exact match, you can use this perl script:
#!/usr/bin/perl
@procs = `ps -x`;
for $proc (@procs ) {
if( $proc =~ /\s+(\d+)\s+\S+\s+\S+\s+\S+\s+(\S+)/ ) {
$pid = $1;
$name = $2;
if( $name =~ /$ARGV[0]/ ) {
print "$pid ";
}
}
}
print "\n";
A perl version
ok, 45 secs between posts sucks...
A perl version
hrmmm I think that osxhints strips \'s this is fixed...
A perl version
the last one was wrong as well... i double quoted it.
A perl version
any of the previous versions would match too much
A perl version
the perl version is much faster too! |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.13 seconds |
|