The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 03:03 AM
simple while loop ali560045 Shell Programming and Scripting 10 12-26-2007 10:44 AM
Simple loop query kutz13 UNIX for Dummies Questions & Answers 2 07-17-2007 03:13 PM
Simple while loop question Brokeback Shell Programming and Scripting 3 07-21-2006 09:04 AM
a simple while loop syno Shell Programming and Scripting 5 04-08-2006 06:45 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 12-14-2007
ali560045's Avatar
ali560045 ali560045 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 328
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-14-2007 at 02:47 AM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:50 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0