Help on this loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thaiZilla
    New Member
    • Jan 2008
    • 16

    Help on this loop

    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
  • bykwzpz
    New Member
    • Jan 2008
    • 12

    #2
    Originally posted by thaiZilla
    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.

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      Originally posted by thaiZilla
      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

      Comment

      Working...