Hi,
Is is possible to zip a folder and all its contents within the folder ( including sub-directories and files) into a zip file? and can regain the same structure if unzipped?
Thanks
Hi,
Is is possible to zip a folder and all its contents within the folder ( including sub-directories and files) into a zip file? and can regain the same structure if unzipped?
Thanks
tar it first then zip the tar file. This syntax works on any UNIX:
cd ./path
tar cvf /tmp/my_archive.tar *
# zip or gzip
gzip /tmp/my_archive.tar
To unpack and use:
mkdir ./my_new_path
cd ./my_new_path
gunzip /tmp/my_archive.tar.gz
cd ./my_new_path
tar xf /tmp/my_archive.tar
Hi,
Yes this can be acheive by the tar and gzip command. Look up the man pages for more details but below is a short example.
This is the dir structure of test, it has sub dirs test1 and test2 and even files underneath.
test/
test/test1/
test/test2/
# you will have to create the archive of the dirs you want by doing this
tar -cvf test.tar test # test.tar is the name you are giving to ur tar file.
# test is the dir. note you can specify multiple dirs by giving a space ex: test1 test 2 ..so on
# once your tar is created, use gzip to compress the tar ball.
gzip test.tar
# if you want to extract the tar you can do so by following :
# gunzip and then extract.
gunzip test.tar.gz /tmp/wherevr # this will un-compress the tar ball.
tar -xvf test.tar /tmp/wherver # this will extract the tar ball with all the sub dirs and files underneath.
Can a mix of tar and other options like -z or something help?
I am just curious and not sure about the options.
you can use the -z option to compress and uncompress directly.
this eliminates the use of an extra command gzip/gunzip
Thanks!
I wondered because I remembered using tar with other options.
Warning: the -z option does not work on all UNIX systems.