By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,667 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,667 IT Pros & Developers. It's quick & easy.

Help on this loop

P: 16
userlist=`who | cut -d " " -f1`
linetotal=`cat $userlist| wc -l`
linenumber='1'

while [ $linenumber -le linetotal ]
do
username=`somestuff` put that in for now

basically i want the username variable to be equal to the first line from who | cut -d " " -f1`...and from the loop move to the next line of `who | cut -d " " -f1` and so on until the loop is cleared...

any ideas thanks
Jan 23 '08 #1
Share this Question
Share on Google+
2 Replies

P: 13
userlist=`who | cut -d " " -f1`
linetotal=`cat $userlist| wc -l`
linenumber='1'

while [ $linenumber -le linetotal ]
do
username=`somestuff` put that in for now

basically i want the username variable to be equal to the first line from who | cut -d " " -f1`...and from the loop move to the next line of `who | cut -d " " -f1` and so on until the loop is cleared...

any ideas thanks

You might consider this:

[code]
userlist=`who | cut -d " " -f1`
for username in $userlist
do
<whatever you need to do with $username>
done
[\CODE]

Let me know if this was helpful.
Jan 29 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
userlist=`who | cut -d " " -f1`
linetotal=`cat $userlist| wc -l`
linenumber='1'

while [ $linenumber -le linetotal ]
do
username=`somestuff` put that in for now

basically i want the username variable to be equal to the first line from who | cut -d " " -f1`...and from the loop move to the next line of `who | cut -d " " -f1` and so on until the loop is cleared...

any ideas thanks
Also, please keep the vulgarities out of your threads. It is not tolerated on this site and this is your warning. I have bolded the word that I replaced the vulgarity with.

Regards,

MODERATOR
Jan 29 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.