Need Unix script to tar directories and sub directories

Posted on 2009-04-22
Last Modified: 2013-12-26
I need a basic script which will tar up a directories and sub-directories plus send the the names of the files its taring to a log file which can be mailx'd to an email address. This tar will be scp'ed to another server and untared after the original files have been removed. Please let me know if you need anything else

Question by:7Souls
    LVL 4

    Accepted Solution

    UNIX/linux way:

    The basic command line

        tar cvf my_archive.tar dirX dirY subdirz  > my_archive_tar.log

    or more compact and with mail option...

       tar cvf my_archive.tar dirX dirY subdirz  | mailx -s "archive log"

    Is this what you want???

    # usage:  cmd <tarfile name> <directory|subdir_path>...


    tar cvf ${tarfile} $* > my_archive_tar.log

    cat my_archive_tar.log | mailx -s "my_archive_tar.log"

    Error handling left to student...
    BTW what operating system and/or shell are you using???



    Author Comment

    Thanks, I apologize for not getting back to you sooner I've been away from work due to an injury. The operating system I'm using is Solaris SunOS 5.9 and I'm using Korn shell.. I'll send you a worikng copy of my script. Later,


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
    This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now