Re: [SLE] how to change users home directories

From: The Purple Tiger (Jon_at_tigersden.demon.co.uk)
Date: 01/30/04

  • Next message: Rikard Johnels: "Re: [SLE] how to change users home directories"
    To: suse-linux-e@suse.com
    Date: Fri, 30 Jan 2004 08:21:49 +0000
    
    

    On Thursday 29 January 2004 21:56, steve-ss wrote:
    > (grep year7 /etc/passwd | awk -F: '{print "mv /home/"$1"
    > /home/year7/"$1}') | cat
    > I don't understand it but it runs OK. Is there a quick one liner to
    > explain how it works?
    > Thanks again, Steve.

    Okay, here we go [afaik :)]
    grep is a powerful pattern matching utility:

    #grep year7 /etc/passwd
    goes through the file /etc/passwd and looks for the string "year7" and
    prints it to "stdout" [i.e. standard output so other programs can
    process the info, or display on screen]
    The " | " is known as a pipe through - basically, run the program to the
    left and feed the output to the program on the right.

    awk is like grep iirc, but more powerful. the -F: runs a program, and
    the stuff after that in the apostrophes is the program itself. It
    prints:
    mv /home/
    The $1 indicates take the first field from the output line from the
    previous program and insert it here, so if your paswd file had "bob" as
    the first field, then it would print "mv /home/bob" :)

    If you follow in the same vein for the rest of it, then you get:
    mv /home/firstfield /home/year7/firstfield

    then the lot is "piped through" cat which just displays it to the screen
    [like "type" on dos/windows]

    Hopefully I haven't confused you more :g:

    Jon

    -- 
    Check the headers for your unsubscription address
    For additional commands send e-mail to suse-linux-e-help@suse.com
    Also check the archives at http://lists.suse.com
    Please read the FAQs: suse-linux-e-faq@suse.com
    

  • Next message: Rikard Johnels: "Re: [SLE] how to change users home directories"