Results 1 to 3 of 3
Hi,
I want to divide a directory into a no. of archives with tar.
For example I have a big directory 'mydir'. I want to make 5 archives mydir1.tar, mydir2.tar, ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 02-26-2005 #1Just Joined!
- Join Date
- Jan 2005
- Location
- Germany
- Posts
- 69
divide a directory into multiple archive files with tar
Hi,
I want to divide a directory into a no. of archives with tar.
For example I have a big directory 'mydir'. I want to make 5 archives mydir1.tar, mydir2.tar, ... mydir5.tar from my big directory ‘mydir’.
Eventually I would like to have a text file with the content of every archive (filename and date).
How can I do that? I didn’t find any tar option which could help me.
ddaas
Last edited
- 03-01-2005 #2Just Joined!
- Join Date
- Feb 2005
- Posts
- 9
You can write a script
to do that:
If you call your script 'myscript' then:Code:#!/bin/sh # USAGE function usage(){ cat << EOF -h print this help and exit. -n tar archive name -d directory to tar EOF } # Default directory dir= # Default tar name tar= while [ $# -ne 0 ]; do case $1 in -h) usage exit ;; -n) shift tar=$1 ;; -d) shift dir=$1 ;; *) echo "Unknown option $1" >&2 exit 1; ;; esac done # Create the tar file tar cf $tar.tar $dir # Create the text file ls -Rl $dir > $tar.txt
should create a tar archive of name 'tarname.tar' with a file 'tarname.txt' listing every files in 'directory' with their dates.Code:myscript -n tarname -d directory
If you assign a value to the variable 'dir' for example you can call
Hope that helps.Code:myscript -n tarname
- 03-03-2005 #3Just Joined!
- Join Date
- Jan 2005
- Location
- Germany
- Posts
- 69
thanks,
I'll try your script.
ddaas


Reply With Quote
