skundu
asked on
"Tar" and "Zip" UNIX files
In my UNIX operating system, I have several files and
directories in my home directory.
How can I "tar" and "zip" the contents of all the files
and directories, subdirectories, files in them together
in a file named "home.tar.zip".
Example: My home directory is: "/home/myname/"
Here are the contents:
/home/myname/>ls
dir1 dir2 file1 file2
/home/myname/dir1/>ls
dir3 file3
/home/myname/dir1/dir3/>ls
file4 file5
/home/myname/dir2/>ls
file6
How can I tar and zip all files/directories/subdirec tories under "/home/myname/" and put it in a file(?) named "home.tar.zip" (From this I should be able to retrieve all the files and directories the same way they used to be before it was tar'ed and zip'ed)
thanks.
directories in my home directory.
How can I "tar" and "zip" the contents of all the files
and directories, subdirectories, files in them together
in a file named "home.tar.zip".
Example: My home directory is: "/home/myname/"
Here are the contents:
/home/myname/>ls
dir1 dir2 file1 file2
/home/myname/dir1/>ls
dir3 file3
/home/myname/dir1/dir3/>ls
file4 file5
/home/myname/dir2/>ls
file6
How can I tar and zip all files/directories/subdirec
thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One of the easiest ways I have found is to use gzip and GNU tar. You can download both at www.sunfreeware.com. One you have these installed, you can type this command:
tar -zcvf home.tgz
With GNU tar, the -z option is added to automatically gzip the files when it creates the tarball. It just makes for less commands, as the other suggestions above are just as good.
Mark
NOTE: Even if you are not using solaris, www.sunfreeware.com has the sourcecode also. You can also check sites related to your specific flavor.
tar -zcvf home.tgz
With GNU tar, the -z option is added to automatically gzip the files when it creates the tarball. It just makes for less commands, as the other suggestions above are just as good.
Mark
NOTE: Even if you are not using solaris, www.sunfreeware.com has the sourcecode also. You can also check sites related to your specific flavor.
ASKER
Thanks a lot everybody...
skundu
skundu
Here's what you can do tp make a tar ball, of your home dir:
(I assume you login as yourself)
1. cd ~
2. tar cvf backup.tar .
where . means that the current dir, you can replace . with the file, dirs you want to put in, eg:
tar cvf backup.tar file1 file2 ... dir1 dir2
To make a compress file of the tar ball, you have a lot of options:
1. use the compress command:
compress backup.tar
this will create a compress file named: backup.tar.Z.
and you use uncompress command to uncompress it
2. use the zip command: (create a backup.tar.zip file)
zip backup.tar.zip backup.tar
use unzip to unzip the file
3. if you have gzip install on your systems:
gzip backup.tar
this will create backup.tar.gz file
and you use gunzip to unzip it.
Note: 1, and 3, will autodelete the backup.tar file after the .Z or .gz file is created. 2 will leave the backup.tar alone.
In some of the UNIX system, you might have to create you tar ball
out side your home dir:
tar cvf /tmp/backup.tar .
mv /tmp/backup.tar .
I hope this can help.
Regards
yuzh