The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,980 other followers

command line – Recursive tar compression? – Ask Ubuntu

Posted by jpluimers on 2020/03/09

Since I always forget one-letter command-line options: [WayBack]command line – Recursive tar compression? – Ask Ubuntu (thanks andrew.46 for this very nice answer!):

Try:

tar -czvf directorios.tar.gz folder

A few notes:

  1. Recursion is the default, from the tar man 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-recursion option…

  2. You need the archive name immediately after the -f option, the correct sequence being:
    tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
             ^^^^^^^^^^
    
  3. For a more flexible command line (particularly if you wanted to use other compression utilities apart from gzip with tar) you could omit the -z option and use -a option 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 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

tar is pretty cool :)

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: