Posts Tagged ‘compress’

Compress a folder with tar

February 15, 2013 1 comment

To archive and compress a folder with tar use this command:

$ tar -czvf folder.tar.gz folder

Be careful with the parameters order: tar -czvf is not the same as tar -cvfz. The fist one is ok, but the second one ends with an error:

$ tar -cvfz folder.tar.gz folder
tar: folder.tar.gz: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

An ls will show a z file. The reason is that the -f parameter takes the next argument as the filename to archive, thus the z file in our folder. So you have to use the tar -czvf syntax.

Categories: linux Tags: , ,

Splitting files with 7zip without compression

January 11, 2013 11 comments

I have to copy a large (12GB) file to an external USB Drive that’s formatted in FAT32, which is limited to a maximum of 4GB per file.

I can split the files with the split command, but the owner of the disk has Windows, so I decided to generate a multipart 7zipped file from command line. As the original file is already compressed, I use no compression switch:

$ 7z a <filename> -mx0 -v4000m <file_to_be_compressed>

The switches stands for:

  • -mx0: level of compression, where 0 means copy mode, i.e., no compression (usr/share/doc/p7zip-full/DOCS/MANUAL/switches/method.htm)
  • -v4000m: create volume size of 4000 MB (/usr/share/doc/p7zip-full/DOCS/MANUAL/switches/volume.htm)

If you use -v4g to generate 4GB chunks, this 4GB will be grater than the FAT32 4GB, and it will be impossible to copy to the FAT32 USB drive .

Once completed, you’ll have several files deppending on the size of the file to compress, named  filename.7z.001, filename.7z.002, …

Categories: ubuntu Tags: , , , ,