4

When reading through man tar, you will see that nowhere is the tar command used without a hyphen. Why then does tar allow the following two commands to be valid:

tar c .
tar -c .
Joseph Casey
  • 1,283
  • 1
  • 14
  • 34
  • Cross-site duplicate: [Why use superflous dash (-) to pass option flags to tar?](http://unix.stackexchange.com/questions/13573/why-use-superflous-dash-to-pass-option-flags-to-tar) – Aurora0001 Nov 21 '16 at 19:52

2 Answers2

7

3.3 The Three Option Styles

There are three styles for writing operations and options to the command line invoking tar. The different styles were developed at different times during the history of tar. These styles will be presented below, from the most recent to the oldest.

https://www.gnu.org/software/tar/manual/html_section/Styles.html#Old-Options

durka42
  • 1,502
  • 10
  • 17
Ipor Sircer
  • 3,069
  • 3
  • 10
  • 15
  • I'm not sure what I expected. I guess "GNU tar supports old options not only for historical reasons," is as much as one could expect. Perhaps it was silly to think there would be a more interesting history worthy of note. – Joseph Casey Nov 21 '16 at 20:03
  • 1
    The link has moved to https://www.gnu.org/software/tar/manual/html_section/Styles.html#Old-Options (submitted as an edit to the answer) – durka42 May 04 '23 at 01:51
0

I use linux mint distrib and see that part of man tar look as

SYNOPSIS
 tar [-] A --catenate --concatenate | c --create | d --diff --compare | --delete | r --append | t --list | --test-label |
     u --update | x --extract --get [options] [pathname ...]

So we see that the hyphen is optional. But we can use it.