RE: Awk scripting Question

From: Brian D. McGrew (brian_at_visionpro.com)
Date: 03/03/05

  • Next message: Rushan Sobar: "heartbeat and updating data between 2 nodes"
    Date: Wed, 2 Mar 2005 17:39:39 -0800
    To: "General Red Hat Linux discussion list" <redhat-list@redhat.com>
    
    

    Or another way would be:

    For f in `cat /tmp/users`
    Do
        grep $f /etc/passwd | awk -F: '{ print $6 }' >> /tmp/xxx
    done

    -brian

    Brian D. McGrew {brian@doubledimension.com || pacemakertaker@rock.com }

    ---
    > Failure is not an option; it is included with every Microsoft product.
    -----Original Message-----
    From: redhat-list-bounces@redhat.com
    [mailto:redhat-list-bounces@redhat.com] On Behalf Of Smith, Albert
    Sent: Wednesday, March 02, 2005 4:09 PM
    To: redhat@chamkila.org; General Red Hat Linux discussion list
    Subject: RE: Awk scripting Question
    How about this:
    for x in `cat /tmp/users`
    	do
    		grep $x /etc/passwd|cut -d":" -f6 >>/tmp/home_dir
    	done
    Albert Smith
    Sr. Unix Systems Administrator
    HPCSA, RHCT
    Genex Services
    440 E. Swedesford Rd.
    Wayne, PA 19087
    albert.smith@genexservices.com
    (610) 964-5154
     
    > -----Original Message-----
    > From: redhat-list-bounces@redhat.com
    > [mailto:redhat-list-bounces@redhat.com] On Behalf Of Simran H.
    > Sent: Wednesday, March 02, 2005 7:01 PM
    > To: redhat-list@redhat.com
    > Subject: Awk scripting Question
    > 
    > Hey Guys,
    > 
    > I am trying to do some cleanup work on one of my linux systems and am 
    > having problems with a script that I am writing.. Hopefully someone 
    > here can help me out:
    > 
    > ls /home_nfs >> /tmp/users
    > foreach user(`cat /tmp/users`)
    >         (echo `grep '/$user:' /home/Home_Script/passwd` | awk -F : 
    > '{print $6}' | awk -F / '{print "/"$2"/"$3}' >>
    > /tmp/home_dir) end
    > 
    > It looks like the script is failing at the echo `grep '/$user:'
    > /home/Home_Script/passwd` part.. Anyone know what I am doing wrong.
    > 
    > What I am trying to achieve is this:
    > 
    > I have a file /tmp/users with all usernames and I want to grep for 
    > those users names in /etc/passwd and create another directory with 
    > just the home dir entries.
    > 
    > Any help would be grately appreciated.
    > 
    > Thanks in advance.
    > 
    > --
    > redhat-list mailing list
    > unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    > https://www.redhat.com/mailman/listinfo/redhat-list
    > 
    > 
    --
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    -- 
    redhat-list mailing list
    unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
    https://www.redhat.com/mailman/listinfo/redhat-list
    

  • Next message: Rushan Sobar: "heartbeat and updating data between 2 nodes"

    Relevant Pages

    • Re: OpenGL glxgears demo program
      ... cat /var/log/Xorg.0.log | grep EE ... Modify settings or unsubscribe at: ...
      (Ubuntu)
    • Re: Contacts printing
      ... Grep is to search for string within files, how can it do sorting jobs? ... I want to cat all those file into one file and then sort the above entries, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: [Partially solved] Re: Locale errors
      ... (which, as far as it goes, matches the output of the 'locale' command). ... rbthomas@greybox:~$ cat /etc/environment ... grep: /etc/ssl/certs/ ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
      (Debian-User)
    • shutdown
      ... To unsubscribe, ...
      (freebsd-stable)
    • Re: An inquiry
      ... then I'm not sure I know how google formats gmail.] ... Output of lsmod | grep snd ... Output of cat /dev/snd/stat No such file or directory. ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)