If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > aix script for tar a folder and moving into another directory

View Poll Results: TARING A FOLDER AND HOW IT MOVE INTO ANOTHER DIRECTORY
Tar command 1 50.00%
MV command 1 50.00%
Voters: 2. You may not vote on this poll

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-22-10, 08:54
sreekum sreekum is offline
Registered User
 
Join Date: Oct 2010
Posts: 1
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 ##
################################################## #######################################
Reply With Quote
  #2 (permalink)  
Old 10-22-10, 14:07
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
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 08:08. Reason: typo
Reply With Quote
  #3 (permalink)  
Old 10-22-10, 16:22
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
if you only want to extract a single directory (folder for MS types) then:

Code:
tar xvf tarfile directoryname
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On