4

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?

2
  • what does the -c switch do? May 15, 2018 at 21:00
  • @AlexanderMills It creates an archive.
    – Kusalananda
    Jul 10, 2019 at 12:36

1 Answer 1

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.

3
  • 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, 2016 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). Dec 21, 2016 at 16:46
  • 2
    Anecdotally, 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. Dec 21, 2016 at 16:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .