Monday, July 5, 2010

Good Habit #2: Change the path; do not move the archive

Another bad usage pattern is moving a .tar archive file to a certain directory because it happens to be the directory you want to extract it in. You never need to do this. You can unpack any .tar archive file into any directory you like -- that is what the -C option is for. Use the -C option when unpacking an archive file to specify the directory to unpack it in:

Listing 1. Example of good habit #2: Using option -C to unpack a .tar archive file

~ $ tar xvf -C tmp/a/b/c newarc.tar.gz
            

Making a habit of using -C is preferable to moving the archive file to where you want to unpack it, changing to that directory, and only then extracting its contents -- especially if the archive file belongs somewhere else.

No comments:

Post a Comment