Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Next: , Previous: create verbose, Up: create


2.6.4 Short Forms with ‘create

As we said before, the --create (-c) operation is one of the most basic uses of tar, and you will use it countless times. Eventually, you will probably want to use abbreviated (or “short”) forms of options. A full discussion of the three different forms that options can take appears in Styles; for now, here is what the previous example (including the --verbose (-v) option) looks like using short option forms:

     $ tar -cvf collection.tar blues folk jazz
     blues
     folk
     jazz

As you can see, the system responds the same no matter whether you use long or short option forms.

One difference between using short and long option forms is that, although the exact placement of arguments following options is no more specific when using short forms, it is easier to become confused and make a mistake when using short forms. For example, suppose you attempted the above example in the following way:

     $ tar -cfv collection.tar blues folk jazz

In this case, tar will make an archive file called v, containing the files blues, folk, and jazz, because the ‘v’ is the closest “file name” to the -f option, and is thus taken to be the chosen archive file name. tar will try to add a file called collection.tar to the v archive file; if the file collection.tar did not already exist, tar will report an error indicating that this file does not exist. If the file collection.tar does already exist (e.g., from a previous command you may have run), then tar will add this file to the archive. Because the -v option did not get registered, tar will not run under ‘verbose’ mode, and will not report its progress.

The end result is that you may be quite confused about what happened, and possibly overwrite a file. To illustrate this further, we will show you how an example we showed previously would look using short forms.

This example,

     $ tar blues --create folk --file=collection.tar jazz

is confusing as it is. When shown using short forms, however, it becomes much more so:

     $ tar blues -c folk -f collection.tar jazz

It would be very easy to put the wrong string of characters immediately following the -f, but doing that could sacrifice valuable data.

For this reason, we recommend that you pay very careful attention to the order of options and placement of file and archive names, especially when using short option forms. Not having the option name written out mnemonically can affect how well you remember which option does what, and therefore where different names have to be placed.

 
 
  Published under the terms of the GNU General Public License Design by Interspire