How can i .gz all files in a directory?
Hello
I was using ssh and go inside the public_html folder of my server that all files from my website are located. What command i must use to compress all the files and folders from that directory to .gz? Thank you |
what about gzip *.* ?
|
try
Code:
tar -czvf directory.tar.gz directory/ |
or simply gzip * ?
|
we do not know if the orignal poster wants each one gziped indiviually or all in one.
|
Do you want to compress all of the files individually, or create a tarball. Where do you want the compressed files (or tarball) located?
If you want to download a tarball of all of the files in this directory on your remote computer, you could use tar through a pipe: ssh user@host -C <base_dir> -czf - . | cat >tarballname.tar.gz |
if i had files A B and C in directory dir
then gzip * would end up with A.gz B.gz and C.gz where tar -czvf dir.tar.gz dir/ would end up with dir.tar.gs that contains all the files inside |
I want all files and folders from public_html to one files.gz
|
Quote:
Code:
tar -czvf directory.tar.gz directory/ |
Ok but i don't think that i must specify the directory as i will run the command when i am already in that folder from ssh or not?
And one more: Why i must have.tar before .gz? Thanks :) |
The program gzip can compress separate files. When you want to compress a lot of files you have first to archive them in one file with tar and then compress it with gzip.
So you could use the commands: tar cf archive.tar * and: gzip archive.tar The resulting file has the name archive.tar.gz. Instead of it you can use z switch in tar command to compress archive on the fly: tar czf archive.tar.gz * It's good to use in that case .tar.gz extension to remember in the future that it's compressed archive. That command gives the same file: tar czf archive.wow! * but the extension .wow! means nothing so it'll be difficult to say in the future what kind of file is archive.wow! If you don't like .tar.gz extension use .tgz one for gzip compressed tar archives. The program bzip offers better compression than gzip: tar cjf archive.tar.bz * Instead of .tar.bz extension you can use .tbz one. To uncompress these files use the commands: tar xf archive.tar.gz and: tar xf archive.tar.bz |
Thank you :)
|
All times are GMT -5. The time now is 07:00 AM. |