Just fixing it
This command shows an error message "ERROR: extract: path must be absolute":
The error is not helpful - the programm was too confused already.
You already know the error is from the
~, as it works with
~ only gets replaced at the start of a word.
For example, this works with the tilde:
echo -extract ~/Downloads
If you need the option syntax with
=, using $HOME instead of
~ is the most clean solution;
What you should know:
There are special cases where
~ get's expanded when not at the beginning of a word: as part of a variable assignment, directly after the
=. Which is confusing here, of course.
The other important special case it for use with variables like PATH. In variable assignments,
~ is also expanded after
:, like after the first
$ dir=~ sh -c 'echo D2: $dir'
$ sh -c 'echo D2: $dir' dir=~
$ echo Dir: $dir
$ dir=~; sh -c 'echo D2: $dir'
$ echo Dir: $dir
$ sh -c 'echo D2: $dir'; d3=~
$ echo d3: $d3
The meaning of the tilde
In a shell,
~, the tilde, is not really a path. It is only replaced by a path,
$HOME, some times.
It is something like a shorthand, or abbreviation, provided by the shell.
It can not be used like a path in general, the shell "expands" it to a path only in very special places.
And even if it is expanded, it can be to something else than the home directory.
- It is only expanded at the beginning of a word, or in a variable assignment after a
- It is only expanded if it is not inside quotes
- It is only expanded to
$HOME if there are no further characters in the word before a
The problem in the command line
According to this, the problem in your command is that the tilde in
is not expanded, because it is not one of the cases listed. That's all.
The solution could be to make the tilde the first unquoted character of a word, with no other character before the next
/ - that is just what you get when you use an option with a space before the option argument:
Another solution would be to use
$HOME instead. In a script, that is usually the better choice.
The error message
But how does the error message
"ERROR: extract: path must be absolute."?
fit into all this?
We know that the tilde did not get expanded. That means the program got the argument text including the
~, but without the
/home/auser as the path. That path is
~/Downloads/nvidia_installers - but now there is no shell, so the tilde has no special meaning. It is just a normal directory name. And as every other path of the form
foo/bar/baz, it is a relative path
If there are characters after the
~, as in
~alice - with all the other rules above applying - and there is a user names
alice, that is expanded to the home directory of
alice instead, say
Also, if you are
~ would expand to
~bob would expand to the same.
~+ is expanded to the current directory,
To refer to the previous directory, where you were before the last
cd, you can use
~-, which is expanded to
If you use
popd, instead of
cd, you will already know that the directory stack can be accessed like
All the cases where
~ is expanded to a path are handeled by the shell. For other programs,
~ is just a normal filename character.
For the exact definition inside the shell, here is the relevant section of
Note how replacing
$HOME is just one special case of many cases: "If this login name is the null string, the tilde is replaced with the value of the shell parameter HOME.":
If a word begins with an unquoted tilde character (`~'), all of the charac‐
ters preceding the first unquoted slash (or all characters, if there is no
unquoted slash) are considered a tilde-prefix. If none of the characters
in the tilde-prefix are quoted, the characters in the tilde-prefix follow‐
ing the tilde are treated as a possible login name. If this login name is
the null string, the tilde is replaced with the value of the shell parame‐
ter HOME. If HOME is unset, the home directory of the user executing the
shell is substituted instead. Otherwise, the tilde-prefix is replaced with
the home directory associated with the specified login name.
If the tilde-prefix is a `~+', the value of the shell variable PWD replaces
the tilde-prefix. If the tilde-prefix is a `~-', the value of the shell
variable OLDPWD, if it is set, is substituted. If the characters following
the tilde in the tilde-prefix consist of a number N, optionally prefixed by
a `+' or a `-', the tilde-prefix is replaced with the corresponding element
from the directory stack, as it would be displayed by the dirs builtin
invoked with the tilde-prefix as an argument. If the characters following
the tilde in the tilde-prefix consist of a number without a leading `+' or
`-', `+' is assumed.
If the login name is invalid, or the tilde expansion fails, the word is
Each variable assignment is checked for unquoted tilde-prefixes immediately
following a : or the first =. In these cases, tilde expansion is also per‐
formed. Consequently, one may use filenames with tildes in assignments to
PATH, MAILPATH, and CDPATH, and the shell assigns the expanded value.