Mike Frysinger wrote: > kc123 wrote: > > For example, my script below called crond.sh: > > ... > > content=`ps auxw | grep [c]rond| awk '{print $11}'` > > ... > > and output is: > > CONTENT: /bin/bash /bin/bash crond > > > > Why are there 2 extra arguments printed (/bin/bash) ? > > because you grepped your own script named "crond.sh" > > make the awk script smarter, or use pgrep
You are using a system that supports various ps options. The equivalent of the BSD 'ps aux' is the SysV 'ps -ef'. They are similar. But then instead of using 'ps aux' BSD style try not printing the full path by using 'ps -e'. You are matching your own grep becuase it is in the argument list. Then this can be made smarter by simply matching it as a string instead of as a pattern. ps -e | awk '$NF=="crond"' ps -e | awk '$NF=="crond"{print$1}' Bob
signature.asc
Description: Digital signature