DISQUS

DISQUS Hello! Tech-Recipes is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Tech-Recipes

Cookbook of Tech Tutorials
Jump to original thread »
Author

Create a TAR archive of a directory | UNIX | Tech-Recipes

Started by qdideas · 9 months ago

No excerpt available. Jump to website »

6 comments

  • The example should be tar -cf archive.tar * (note the hyphen)
  • It may look funny without it, but the hyphen is optional. The traditional syntax for tar does not use the hyphen for command line options that we've become used to using. Likewise, the GNU double hyphen options are a relatively new addition to UNIX.

    For example, here is an excerpt from the Solaris 9 man page for tar:
    tar c [ bBeEfFhiklnopPqvwX@ [0-7]] [block] [tarfile]
    [exclude-file] {-I include-file | -C directory | file |
    file} ...

    I don't know when the hyphen options were implemented in tar, but I suspect that there are still versions of tar that would gag on a -cf. The hyphenless syntax should work everywhere.
  • NAME
    tar - The GNU version of the tar archiving utility

    SYNOPSIS
    tar [ - ] A --catenate --concatenate | c --create | d --diff --compare | r --append | t --list | u
    --update | x -extract --get [ --atime-preserve ] [ -b, --block-size N ] [ -B, --read-full-blocks ] [ -C,
    --directory DIR ] [ --checkpoint ] [ -f, --file [HOSTNAME:]F ] [ --force-local ] [ -F, --info-script
    F --new-volume-script F ] [ -G, --incremental ] [ -g, --listed-incremental F ] [ -h, --dereference ] [
    -i, --ignore-zeros ] [ -j, -I, --bzip ] [ --ignore-failed-read ] [ -k, --keep-old-files ] [ -K, --start-
    ing-file F ] [ -l, --one-file-system ] [ -L, --tape-length N ] [ -m, --modification-time ] [ -M, --multi-
    volume ] [ -N, --after-date DATE, --newer DATE ] [ -o, --old-archive, --portability ] [ -O, --to-stdout ]
    [ -p, --same-permissions, --preserve-permissions ] [ -P, --absolute-paths ] [ --preserve ] [ -R,
    --record-number ] [ --remove-files ] [ -s, --same-order, --preserve-order ] [ --same-owner ] [ -S,
    --sparse ] [ -T, --files-from=F ] [ --null ] [ --totals ] [ -v, --verbose ] [ -V, --label NAME ] [
    --version ] [ -w, --interactive, --confirmation ] [ -W, --verify ] [ --exclude FILE ] [ -X,
    --exclude-from FILE ] [ -Z, --compress, --uncompress ] [ -z, --gzip, --ungzip ] [ --use-compress-
    program PROG ] [ --block-compress ] [ -[0-7][lmh] ]

    filename1 [ filename2, ... filenameN ]

    directory1 [ directory2, ...directoryN ]
  • Yeah, even with GNU tar, the hyphen is optional as indicated by the square brackets around the hyphen like [ - ] .. there are so many scripts and old timers like me around who user tar with the old hyphenless syntax that it would be miserable if it didn't work anymore.
  • How to tar a folder which contains list subfolders in unix.Please get back to me immediately<font color="red"></font>
  • Thanks for saving my time with this posting.

Add New Comment

Returning? Login