Checking a Varaible
This is a part of my shell... echo -n "PID: "
How can I check tmpPID is numeric and there is whether a process with the PID before kill? or probably say, how to check whether it is a integer? /-----------------------------/ To test if a value is numeric you can do : if expr "$value" : '[0-9]\+$' >/dev/null
With ksh, you can also do : if [[ "$value" = +([0-9]) ]] /-----------------------------/ How about checking of PID? You can try something like this : if [ -n "`ps -e | awk "\$1==$PID" ]
assume that 'ps -e' display pid in col 1
Have a Unix Problem
Unix Books :-
Return to : - Unix System Administration Hints and Tips (c) www.gotothings.com All material on this site is Copyright.
|