Quote:
Originally Posted by heyduke25
pwc101
thanks for the reply. i will read thru the link you provided. it has been a while since i used tar to create an archive and i was depending on the man page, my mistake. here again are the man page examples. they appear to be incorrect (or perhaps i am a poor reader.)
EXAMPLES
tar -xvf foo.tar
verbosely extract foo.tar
tar -xzf foo.tar.gz
extract gzipped foo.tar.gz
tar -cjf foo.tar.bz2 bar/
create bzipped tar archive of the directory bar called
foo.tar.bz2
try the third example and you will likely get a failed archive. hate to sound like an old fuddy duddy but i miss the ancient unix man pages.
many thanks for the help
|
The third example works fine for me.
The important difference is when the options are preceded by a -, then any of those options which require arguments must have those arguments follow the option. However, if the options are not preceded by a -, then any arguments to options which require them must follow the cluster of options in the same order as the options which require them are specified. This is remarkably hard to explain!
For example, let's take three options and work with those.
f - this option requires an argument, in this case,
foo.tar.
b - this option requires an argument to specify the block size, we'll use
20.
c - this option does not require an argument, it just tells tar we want to make a new archive.
Using the syntax which does not require a - means any options (c,
b and
f in this case) must follow tar, and must not have a space in them:
Code:
tar bfc 20 foo.tar /bar
Of the two options which require arguments,
b comes first, so its argument must come first after the cluster of arguments. The
f comes after the
b, so its argument comes second. Since c has no arguments, we can put this anywhere in the combination:
Code:
tar cbf 20 foo.tar bar/
tar bcf 20 foo.tar bar/
tar bfc 20 foo.tar bar/
These are all synonymous.
When the options are preceded by a -, then the argument must follow the option:
Code:
tar -c -b 20 -f foo.tar bar/
Here, each option has its corresponding argument following it.
In your example, you had only one option which required an argument, in which case you can group the options which don't require an argument, and the one the does require an argument must be last in that group, and the argument has to follow it:
Code:
tar -cvf foo.tar bar/
If you put the arguments in a different order when using the - syntax, then whatever follows f will become the file name:
Code:
tar -cfv foo.tar bar/
would create an archive called v which contains foo.tar (if it existed) and the contents of /bar.
Hope this helps.