View Poll Results: TARING A FOLDER AND HOW IT MOVE INTO ANOTHER DIRECTORY

Voters
2. You may not vote on this poll
  • Tar command

    1 50.00%
  • MV command

    1 50.00%
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Unanswered: aix script for tar a folder and moving into another directory

    Need to run a Unix Aix Shell Script should contains

    1)Find all the folders in the directory /fss/fin.

    2)Tar the Folders.
    3)Move the Tar folders into another directory /fs/fi which in server .s11003232sz.net

    4)When user requests untar the Folders and move it back to the orignal directory /fss/fi

    Please help

    Below script is not working since there is no GNU


    Code:
    #!/usr/bin/ksh

    ################################################## #######################################
    ## THIS SCRIPT BEGINS HERE ##
    ################################################## #######################################

    #Check for the all folders in the Directory

    find /fss/fin -type d -name "*" -print

    # Tar the Folders in the current directory and Move it into separate server directory

    (cd /fss/fin ; find * -maxdepth 0 -type d -print 0 | xargs -0 tar -cvf -) |
    tar -xf - -C / fs/fi

    ################################################## #######################################
    ## THIS SCRIPT ENDS HERE ##
    ################################################## #######################################

  2. #2
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    Code:
    #!/bin/ksh
    cd /fss/fi
    today=`date "+%Y%m%d"`
    tar cvf $today.tar *
    mv $today.tar .s11003232sz.net     # You have to fix up this line.
    Restore:
    Code:
    #!/bin/ksh
    echo -e "Enter Date to Restore\c"
    read date
    cd /fss/fi
    mv .s11003232sz.net/$date.tar work.tar #and this line
    tar xvf work.tar
    tar will automatically copy a directory and all its contents, you do not need to use find.
    And you may or may not need the -e flag on the echo command.
    Last edited by kitaman; 10-23-10 at 09:08. Reason: typo

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    if you only want to extract a single directory (folder for MS types) then:

    Code:
    tar xvf tarfile directoryname

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •