Why use superflous dash (-) to pass option flags to tar?
To create a tar file for a directory, the tar
command with compress
, verbose
and file
options can be typed thus:
$ tar -cvf my.tar my_directory/
But it also works to do it this way:
$ tar cvf my.tar my_directory/
That is, without the dash (-) preceding the options. Why would you ever pass a dash (-) to the option list?
utilities tar
migrated from stackoverflow.com May 22 '11 at 2:06
This question came from our site for professional and enthusiast programmers.
add a comment |
To create a tar file for a directory, the tar
command with compress
, verbose
and file
options can be typed thus:
$ tar -cvf my.tar my_directory/
But it also works to do it this way:
$ tar cvf my.tar my_directory/
That is, without the dash (-) preceding the options. Why would you ever pass a dash (-) to the option list?
utilities tar
migrated from stackoverflow.com May 22 '11 at 2:06
This question came from our site for professional and enthusiast programmers.
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01
add a comment |
To create a tar file for a directory, the tar
command with compress
, verbose
and file
options can be typed thus:
$ tar -cvf my.tar my_directory/
But it also works to do it this way:
$ tar cvf my.tar my_directory/
That is, without the dash (-) preceding the options. Why would you ever pass a dash (-) to the option list?
utilities tar
To create a tar file for a directory, the tar
command with compress
, verbose
and file
options can be typed thus:
$ tar -cvf my.tar my_directory/
But it also works to do it this way:
$ tar cvf my.tar my_directory/
That is, without the dash (-) preceding the options. Why would you ever pass a dash (-) to the option list?
utilities tar
utilities tar
edited May 22 '11 at 15:43
Gilles
533k12810721594
533k12810721594
asked May 21 '11 at 23:26
MilktraderMilktrader
24335
24335
migrated from stackoverflow.com May 22 '11 at 2:06
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com May 22 '11 at 2:06
This question came from our site for professional and enthusiast programmers.
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01
add a comment |
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01
add a comment |
5 Answers
5
active
oldest
votes
There are several different patterns for options that have been used historically in UNIX applications. Several old ones, like tar, use a positional scheme:
command options arguments
as for example tar uses
tar *something*f "file operated on" *"paths of files to manipulate"*
In a first attempt to avoid the confusion, tar and a few other programs with the old flags-arguments style allowed delimiting the flags with dashes, but most of us old guys simply ignored that.
Some other commands have a more complicated command line syntax, like dd(1) which uses flags, equal signs, pathnames, arguments and a partridge in a pear tree, all with wild abandon.
In BSD and later versions of unix, this had more or less converged to single-character flags marked with '-', but this began to present a couple of problems:
- the flags could be hard to remember
- sometimes you actually wanted to use a name with '-'
- and especially with GNU tools, there began to be limitations imposed by the number of possible flags. So GNU tools added GNU long options like
--output
.
Then Sun decided that the extra '-' was redundant and started using long-style flags with single '-'s.
And that's how it came to be the mess it is now.
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single-
. Is that from Sun?
– mattdm
May 22 '11 at 2:29
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
Another old one which doesn't use dashes isdd
. All of its arguments are optional, usingkey=val
syntax. Sincedd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.
– Kaz
Jul 17 '17 at 18:15
|
show 5 more comments
You can give tar options in the standard unix manner tar -c -f foo -v -B file1 file2 file3
where you need the dash to differentiate between options and parameters or the file names at the end of the command line. Or you can put all the options together in the first argument, in which case the dash is optional.
Then there is ps
, where you use the dashes if you're using the SysV-ish options, and leave them out if you're using BSD-ish options, just to make things more confusing.
And lets not even talk about find
.
add a comment |
The dash is used in order to disambiguate between an option parameter names and values. I guess it's more of a standard convention.
1
I was going to add thebest-practice
tag because I thought it may come down to that.
– Milktrader
May 21 '11 at 23:30
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
add a comment |
There are up to four conventions to use unix command line options:
- -o -p -t (dash before each option)
- -opt (dash before a set of options)
- opt (no dash before a set of options)
- --long-option (double dash before an option name)
For example:
$ tar -x -v -z -f package.tar.gz
$ tar -xvzf package.tar.gz
$ tar xvzf package.tar.gz
$ tar --extract -verbose -gzip -file package.tar.gz
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
add a comment |
With leading minus/dash sign (-) you need to keep the options in accurate order. Without minus order of your option can change.
For example:
#tar -xvf yourfile.tar
#tar vxf yourfile.tar
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f13573%2fwhy-use-superflous-dash-to-pass-option-flags-to-tar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
5 Answers
5
active
oldest
votes
5 Answers
5
active
oldest
votes
active
oldest
votes
active
oldest
votes
There are several different patterns for options that have been used historically in UNIX applications. Several old ones, like tar, use a positional scheme:
command options arguments
as for example tar uses
tar *something*f "file operated on" *"paths of files to manipulate"*
In a first attempt to avoid the confusion, tar and a few other programs with the old flags-arguments style allowed delimiting the flags with dashes, but most of us old guys simply ignored that.
Some other commands have a more complicated command line syntax, like dd(1) which uses flags, equal signs, pathnames, arguments and a partridge in a pear tree, all with wild abandon.
In BSD and later versions of unix, this had more or less converged to single-character flags marked with '-', but this began to present a couple of problems:
- the flags could be hard to remember
- sometimes you actually wanted to use a name with '-'
- and especially with GNU tools, there began to be limitations imposed by the number of possible flags. So GNU tools added GNU long options like
--output
.
Then Sun decided that the extra '-' was redundant and started using long-style flags with single '-'s.
And that's how it came to be the mess it is now.
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single-
. Is that from Sun?
– mattdm
May 22 '11 at 2:29
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
Another old one which doesn't use dashes isdd
. All of its arguments are optional, usingkey=val
syntax. Sincedd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.
– Kaz
Jul 17 '17 at 18:15
|
show 5 more comments
There are several different patterns for options that have been used historically in UNIX applications. Several old ones, like tar, use a positional scheme:
command options arguments
as for example tar uses
tar *something*f "file operated on" *"paths of files to manipulate"*
In a first attempt to avoid the confusion, tar and a few other programs with the old flags-arguments style allowed delimiting the flags with dashes, but most of us old guys simply ignored that.
Some other commands have a more complicated command line syntax, like dd(1) which uses flags, equal signs, pathnames, arguments and a partridge in a pear tree, all with wild abandon.
In BSD and later versions of unix, this had more or less converged to single-character flags marked with '-', but this began to present a couple of problems:
- the flags could be hard to remember
- sometimes you actually wanted to use a name with '-'
- and especially with GNU tools, there began to be limitations imposed by the number of possible flags. So GNU tools added GNU long options like
--output
.
Then Sun decided that the extra '-' was redundant and started using long-style flags with single '-'s.
And that's how it came to be the mess it is now.
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single-
. Is that from Sun?
– mattdm
May 22 '11 at 2:29
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
Another old one which doesn't use dashes isdd
. All of its arguments are optional, usingkey=val
syntax. Sincedd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.
– Kaz
Jul 17 '17 at 18:15
|
show 5 more comments
There are several different patterns for options that have been used historically in UNIX applications. Several old ones, like tar, use a positional scheme:
command options arguments
as for example tar uses
tar *something*f "file operated on" *"paths of files to manipulate"*
In a first attempt to avoid the confusion, tar and a few other programs with the old flags-arguments style allowed delimiting the flags with dashes, but most of us old guys simply ignored that.
Some other commands have a more complicated command line syntax, like dd(1) which uses flags, equal signs, pathnames, arguments and a partridge in a pear tree, all with wild abandon.
In BSD and later versions of unix, this had more or less converged to single-character flags marked with '-', but this began to present a couple of problems:
- the flags could be hard to remember
- sometimes you actually wanted to use a name with '-'
- and especially with GNU tools, there began to be limitations imposed by the number of possible flags. So GNU tools added GNU long options like
--output
.
Then Sun decided that the extra '-' was redundant and started using long-style flags with single '-'s.
And that's how it came to be the mess it is now.
There are several different patterns for options that have been used historically in UNIX applications. Several old ones, like tar, use a positional scheme:
command options arguments
as for example tar uses
tar *something*f "file operated on" *"paths of files to manipulate"*
In a first attempt to avoid the confusion, tar and a few other programs with the old flags-arguments style allowed delimiting the flags with dashes, but most of us old guys simply ignored that.
Some other commands have a more complicated command line syntax, like dd(1) which uses flags, equal signs, pathnames, arguments and a partridge in a pear tree, all with wild abandon.
In BSD and later versions of unix, this had more or less converged to single-character flags marked with '-', but this began to present a couple of problems:
- the flags could be hard to remember
- sometimes you actually wanted to use a name with '-'
- and especially with GNU tools, there began to be limitations imposed by the number of possible flags. So GNU tools added GNU long options like
--output
.
Then Sun decided that the extra '-' was redundant and started using long-style flags with single '-'s.
And that's how it came to be the mess it is now.
answered May 21 '11 at 23:40
Charlie MartinCharlie Martin
51846
51846
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single-
. Is that from Sun?
– mattdm
May 22 '11 at 2:29
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
Another old one which doesn't use dashes isdd
. All of its arguments are optional, usingkey=val
syntax. Sincedd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.
– Kaz
Jul 17 '17 at 18:15
|
show 5 more comments
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single-
. Is that from Sun?
– mattdm
May 22 '11 at 2:29
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
Another old one which doesn't use dashes isdd
. All of its arguments are optional, usingkey=val
syntax. Sincedd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.
– Kaz
Jul 17 '17 at 18:15
9
9
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
"and a partridge in a pear tree" Better than my dry attempt. You win.
– dmckee
May 21 '11 at 23:48
1
1
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single
-
. Is that from Sun?– mattdm
May 22 '11 at 2:29
I notice that a lot of X programs (including, say, X, from Xorg), use long-style flags with a single
-
. Is that from Sun?– mattdm
May 22 '11 at 2:29
1
1
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
What is the meanig of ‘partridge in a pear tree’? (Can I have any useful & easy-to-understand link?)
– plhn
Sep 2 '16 at 9:18
1
1
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
@plhn Idiom. A traditional English Christmas carol "The Twelve Days of Christmas" lists a whole bunch of extravagant gifts, ending with "a partridge in a pear tree". It suggests a long extravagant list.
– Charlie Martin
Sep 2 '16 at 15:45
1
1
Another old one which doesn't use dashes is
dd
. All of its arguments are optional, using key=val
syntax. Since dd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.– Kaz
Jul 17 '17 at 18:15
Another old one which doesn't use dashes is
dd
. All of its arguments are optional, using key=val
syntax. Since dd
's arguments don't have to be distinguished from non-optionals, they don't have a leading dash.– Kaz
Jul 17 '17 at 18:15
|
show 5 more comments
You can give tar options in the standard unix manner tar -c -f foo -v -B file1 file2 file3
where you need the dash to differentiate between options and parameters or the file names at the end of the command line. Or you can put all the options together in the first argument, in which case the dash is optional.
Then there is ps
, where you use the dashes if you're using the SysV-ish options, and leave them out if you're using BSD-ish options, just to make things more confusing.
And lets not even talk about find
.
add a comment |
You can give tar options in the standard unix manner tar -c -f foo -v -B file1 file2 file3
where you need the dash to differentiate between options and parameters or the file names at the end of the command line. Or you can put all the options together in the first argument, in which case the dash is optional.
Then there is ps
, where you use the dashes if you're using the SysV-ish options, and leave them out if you're using BSD-ish options, just to make things more confusing.
And lets not even talk about find
.
add a comment |
You can give tar options in the standard unix manner tar -c -f foo -v -B file1 file2 file3
where you need the dash to differentiate between options and parameters or the file names at the end of the command line. Or you can put all the options together in the first argument, in which case the dash is optional.
Then there is ps
, where you use the dashes if you're using the SysV-ish options, and leave them out if you're using BSD-ish options, just to make things more confusing.
And lets not even talk about find
.
You can give tar options in the standard unix manner tar -c -f foo -v -B file1 file2 file3
where you need the dash to differentiate between options and parameters or the file names at the end of the command line. Or you can put all the options together in the first argument, in which case the dash is optional.
Then there is ps
, where you use the dashes if you're using the SysV-ish options, and leave them out if you're using BSD-ish options, just to make things more confusing.
And lets not even talk about find
.
answered May 21 '11 at 23:36
Paul TomblinPaul Tomblin
1,3651015
1,3651015
add a comment |
add a comment |
The dash is used in order to disambiguate between an option parameter names and values. I guess it's more of a standard convention.
1
I was going to add thebest-practice
tag because I thought it may come down to that.
– Milktrader
May 21 '11 at 23:30
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
add a comment |
The dash is used in order to disambiguate between an option parameter names and values. I guess it's more of a standard convention.
1
I was going to add thebest-practice
tag because I thought it may come down to that.
– Milktrader
May 21 '11 at 23:30
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
add a comment |
The dash is used in order to disambiguate between an option parameter names and values. I guess it's more of a standard convention.
The dash is used in order to disambiguate between an option parameter names and values. I guess it's more of a standard convention.
answered May 21 '11 at 23:29
Darin Dimitrov
1
I was going to add thebest-practice
tag because I thought it may come down to that.
– Milktrader
May 21 '11 at 23:30
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
add a comment |
1
I was going to add thebest-practice
tag because I thought it may come down to that.
– Milktrader
May 21 '11 at 23:30
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
1
1
I was going to add the
best-practice
tag because I thought it may come down to that.– Milktrader
May 21 '11 at 23:30
I was going to add the
best-practice
tag because I thought it may come down to that.– Milktrader
May 21 '11 at 23:30
1
1
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
@Milktrader, it's a difficult question when talking about best practices. Following standard conventions is indeed best practice, but whether you want to do it in your cases it's not clear. It will depend on your scenario. If you are hacking some quick command in the shell you probably wouldn't care much about it but if you are writing a library it is important to follow well established conventions because you don't have control of how this library is going to be used by clients. In this case you should cover all possible cases and disambiguating between option names and values is important.
– Darin Dimitrov
May 21 '11 at 23:33
add a comment |
There are up to four conventions to use unix command line options:
- -o -p -t (dash before each option)
- -opt (dash before a set of options)
- opt (no dash before a set of options)
- --long-option (double dash before an option name)
For example:
$ tar -x -v -z -f package.tar.gz
$ tar -xvzf package.tar.gz
$ tar xvzf package.tar.gz
$ tar --extract -verbose -gzip -file package.tar.gz
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
add a comment |
There are up to four conventions to use unix command line options:
- -o -p -t (dash before each option)
- -opt (dash before a set of options)
- opt (no dash before a set of options)
- --long-option (double dash before an option name)
For example:
$ tar -x -v -z -f package.tar.gz
$ tar -xvzf package.tar.gz
$ tar xvzf package.tar.gz
$ tar --extract -verbose -gzip -file package.tar.gz
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
add a comment |
There are up to four conventions to use unix command line options:
- -o -p -t (dash before each option)
- -opt (dash before a set of options)
- opt (no dash before a set of options)
- --long-option (double dash before an option name)
For example:
$ tar -x -v -z -f package.tar.gz
$ tar -xvzf package.tar.gz
$ tar xvzf package.tar.gz
$ tar --extract -verbose -gzip -file package.tar.gz
There are up to four conventions to use unix command line options:
- -o -p -t (dash before each option)
- -opt (dash before a set of options)
- opt (no dash before a set of options)
- --long-option (double dash before an option name)
For example:
$ tar -x -v -z -f package.tar.gz
$ tar -xvzf package.tar.gz
$ tar xvzf package.tar.gz
$ tar --extract -verbose -gzip -file package.tar.gz
answered Dec 14 '16 at 8:11
jonasjacekjonasjacek
316
316
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
add a comment |
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
1
1
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
Is that convention only applicable to tar? What about ls? ls lrt wont work but ls -lrt / ls -l -r -t will work. Why so?
– Shashank Vyas
Jan 15 '17 at 17:56
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
The four conventions should work for all commands.
– jonasjacek
Jan 16 '17 at 13:30
2
2
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
No they don't. The other day I tried rm rf <filename>, that also doesn't work.
– Shashank Vyas
Jan 30 '17 at 0:27
add a comment |
With leading minus/dash sign (-) you need to keep the options in accurate order. Without minus order of your option can change.
For example:
#tar -xvf yourfile.tar
#tar vxf yourfile.tar
New contributor
add a comment |
With leading minus/dash sign (-) you need to keep the options in accurate order. Without minus order of your option can change.
For example:
#tar -xvf yourfile.tar
#tar vxf yourfile.tar
New contributor
add a comment |
With leading minus/dash sign (-) you need to keep the options in accurate order. Without minus order of your option can change.
For example:
#tar -xvf yourfile.tar
#tar vxf yourfile.tar
New contributor
With leading minus/dash sign (-) you need to keep the options in accurate order. Without minus order of your option can change.
For example:
#tar -xvf yourfile.tar
#tar vxf yourfile.tar
New contributor
New contributor
answered 5 mins ago
Mohd. Golam HossainMohd. Golam Hossain
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f13573%2fwhy-use-superflous-dash-to-pass-option-flags-to-tar%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
See also: unix.stackexchange.com/questions/28403/tar-cvf-or-tar-cvf
– unor
Apr 8 '13 at 10:01