#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    262
    Rep Power
    14

    Shell Script to List Directories...


    Hello,

    I am new to shell scripting. I am running Red Hat using Bash. I am trying to create a little script that will loop through the -sub-directories of the systems home directory, and then recursively zip up the contents of each one saving it as the name of that particularly directory.

    I cannot figure out how to do this. Can anyone help?

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    114
    Rep Power
    14
    #!/usr/bin/local/bash
    #
    # cd to the directory you want to backup first.
    # You could also easily modify the script to take
    #command line arguments.
    for user in $( ls . )
    do
    tar czvf /back_up_dir/$user.tar.gz $user
    done

IMN logo majestic logo threadwatch logo seochat tools logo