The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
a simple loop in csh dsstamps UNIX for Dummies Questions & Answers 1 05-22-2008 12:03 AM
simple while loop ali560045 Shell Programming and Scripting 10 12-26-2007 07:44 AM
Simple loop query kutz13 UNIX for Dummies Questions & Answers 2 07-17-2007 12:13 PM
Simple while loop question Brokeback Shell Programming and Scripting 3 07-21-2006 06:04 AM
a simple while loop syno Shell Programming and Scripting 5 04-08-2006 03:45 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-13-2007
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
simple for loop

i have the following process running in background:
when i give "ps -lef"
------------------------------------------------------------------------

user2
user1
user1
user3
user1
user4
user5
user4
user3
user4
user2
user1
user1
user3
user1
user4
user5
user4
user3
user4
----------------------------------------------------------------------


i have the script

#!/bin/ksh

for i in user1 user2 user3 user4 user5
do
count=0
((count=`ps -lef | grep -c $i` - 1))

echo $i ech $count
done
-------------------------------------------------------------------
its giving o/p as
user1 6
user2 2
user3 4
user4 6
user5 2
---------------------------------------------------------------

i want to use only "user" in "for" loop as
-------------for i in user-----------------

and it should count the user for 1 to 5..

can u help me in this.....is there any way

Last edited by ali560045; 12-13-2007 at 11:47 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 12-14-2007
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
still not getting the o/p
Reply With Quote
  #3  
Old 12-14-2007
Moderator
 

Join Date: Dec 2003
Location: /dev/fl
Posts: 1,061
What o/p are you expecting? Your question makes no sense. What is the point of the for loop if you are only passing in a string called "user"?
for i in 1 2 3 4 5 makes sense, not for i in user.
Reply With Quote
  #4  
Old 12-16-2007
ali560045's Avatar
Registered User
 

Join Date: Oct 2007
Posts: 265
look i want to just access user1............................user5,by just writting user in for loop..........

i m not getting how to use this logic in my for loop
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0