In the synopsis section of the manual page for tar
, it reads tar -c [-f ARCHIVE] [OPTIONS] [FILE...]
. Knowing arguments in the brackets []
are optional, it seems we must be able to use tar -c
without any more options or arguments. Is there an example of it? Or am I misunderstanding the meaning of []
in the synopsis?
Asked
Active
Viewed 502 times
4

Jeff Schaller
- 67,283
- 35
- 116
- 255

Kun
- 276
-
what does the -c switch do? – Alexander Mills May 15 '18 at 21:00
-
@AlexanderMills It creates an archive. – Kusalananda Jul 10 '19 at 12:36
1 Answers
5
Neither the way that you have read the manual nor the way the manual was written is a mistake; it's just that most of us no longer use a tape drive, so the option to use -f
does not make immediate sense. tar
means tape archiver. We have to use -f
to tell tar
not to use the tape drive. But from the utility's "point of view," it is still foremost a tape archiver, so -f
is indeed an option.
How to use 'tar -c' without any optional arguments?
Use a tape drive!
July 10, 2019
Thanks to @roaima for his comment in another question, it may be possible to set the TAPE
variable to /dev/null
in order to use tar -c
: export TAPE=/dev/null; tar -c
or TAPE=/dev/null tar -c
.

Christopher
- 15,911
-
I see that the TAPE environment variable could also serve as a 'virtual tape', would you mind explaining what TAPE should be set to in order to get the desired effect? An example will be great! – Kun Dec 21 '16 at 16:32
-
How to make a virtual tape drive? You got me. The
TAPE
environment variable is used to specify a device file other than the default (compiled in) tape device name (/dev/mt
most likely). – Christopher Dec 21 '16 at 16:46 -
2Anecdotally, the question took me back to 1992. I was working in a mom-and-pop hardware store and frequently used
tar
with an actual tape drive to extract engineering files that the Ford Motor Company would distribute to the industries that produced their parts. Not many at that time knew how to work with a Unix tape archive, so I set up a FreeBSD workstation for that purpose. Linux had just hit the scene. The extracted files were copied to a FAT-formatted disk and handed over to the customer. – Christopher Dec 21 '16 at 16:55