June 2017
Beginner
502 pages
11h 26m
English
The dash is the option character, and usually, it denotes an optional parameter on a command line:
ps -ax
It is also used in parameter substitution as the prefix for the default parameter, and it is also used to redirect from/to stdin/stdout:
zarrelli:~$ cat -112233^C
Or, it can do this:
zarrelli:~$ tar cvzf - $(ls text.file) > zipped.tgzzarrelli:~$ tar -tf zipped.tgz text.file
What we did is get the file name on the stdout using the command substitution, have it read from the stdin with the -, then the result of the tar operation redirected to the stdout to create the zipped file.
We can also use the dash to go back to our previous directory as held in the environmental $OLDPWD variable:
zarrelli:~$ mkdir -p dir1/dir2 ...
Read now
Unlock full access