![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
That is not a good way to do what you need. how about this? You may want add the -w grep option depending on your requirements. This can prevent false positives. See the man page for details. Code:
if w -h | grep -q $uname then exit 0 fi or Code:
w -h |grep -q $uname || exit 0 |
|
||||
|
Quote:
Code:
if [ `w -h | grep root | wc -l` -eq 0 ];then echo "do something" fi |
|
||||
|
thank you frank_rizzo & ghostdog74
syntax-wise the code works. but...the wc is counting 1 when its supposed to count 0. this code is a part of a script that is supposed to weed out invalid users. if the $uname is invalid then there will be no processes running under that user. i thought of adding grep -v grep and the count is now 0. but that doesn't make sense.thanks again. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|