I'd like to create a tar file to compress a folder that contains sub folders. I'm trying with the following command int in the terminal:
tar -czf folder directorios.tar.gzdirectorios.tar.gz would be the result
1 Answer
Try:
tar -czvf directorios.tar.gz folderA few notes:
Recursion is the default, from the
tarman pages:-c, --create Create a new archive. Arguments supply the names of the files to be archived. Directories are archived recursively, unless the --no-recursion option is given.Although this can be turned off by using the
--no-recursionoption...You need the archive name immediately after the
-foption, the correct sequence being:tar -c [-f ARCHIVE] [OPTIONS] [FILE...] ^^^^^^^^^^For a more flexible command line (particularly if you wanted to use other compression utilities apart from gzip with tar) you could omit the
-zoption and use-aor--auto-compressoption to allow tar to automatically decide which compressor to use based on the archive suffix:-a, --auto-compress Use archive suffix to determine the compression program.Recognised suffixes (and their attendant compressing applications) are:
- .gz : gzip
- .tgz : gzip
- .taz : gzip
- .z : compress
- .taZ : compress
- .bz2 : bzip2
- .tz2 : bzip2
- .tbz2 : bzip2
- .tbz : bzip2
- .lz : lzip
- .lzma : lzma
- .tlz : lzma
- .lzo : lzop
- .xz : xz
- .zst : zstd
- .tzst : zstd
tar is pretty cool :)
References:
- 8.1.1 Creating and Reading Compressed Archives Sound information on using the auto-compress options with tar as well as the possibilities for accomplishing the same goal with a more manual and flexible option...