This question already has answers here:
What's the magic of "-" (a dash) in command-line parameters?
(5 answers)
Closed 1 year ago.
I tried to add generated ssh id_rsa to the gitlab-ci.
Command I have found is echo "$SSH_PRIVATE_KEY" | ssh-add -.
I can not find any information about param - that was added to command ssh-add.
How can I interprate this?
In a man I have found information about running it without any argument and some flags but add single dash is not describe there.
I used ubuntu latest image for this process
As #Aaron said
It's a reference to the standard input of the command, so the output of the piped echo
Related
This question already has answers here:
What's the magic of "-" (a dash) in command-line parameters?
(5 answers)
Closed 1 year ago.
I see this command:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python -
What does this to? What is the "-" called in bash?
This has nothing to do with bash. - has a very specific meaning when passed to the python binary:
-
Read commands from standard input (sys.stdin). [...]
Since, in your example,
curl outputs the downloaded file to stdout and
the shell pipe | passes curl's output to python's stdin,
python will execute the commands contained in the file downloaded by curl.
Note that this is a convention commonly found in various command-line utilities: Providing a single hyphen in place of a file name causes the command to read input from stdin instead of a file.
This question already has an answer here:
Bash how do you capture stderr to a variable? [duplicate]
(1 answer)
Closed 3 years ago.
I am trying to automate the installation of nginx on multiple servers, and I have a shell script. It runs a version check if nginx is already installed and its version.
Trying to assign TMP=$(nginx -v), and instead of storing it in the variable it prints the results to console. printf "$TMP" prints an empty string
The problem is that your command does not print to STDOUT but to STDERR.
Using:
TMP=$(nginx -v 2>&1)
will solve your issue, see here for more details.
This question already has answers here:
Is there a "standard" format for command line/shell help text?
(11 answers)
Closed 7 years ago.
What is the convention for showing the usage of a bash script ?
Below is the help output for my script
Usage: my_script [options] [PORT]
Options:
--help print help and exit
--version print version and exit
Am i right in thinking that [ ] means optional
How do I signify an optional argument and a mandatory argument ?
A couple of commandline tools that i use frequently is "find" and "grep". While find runs happy without any parameters (all parameters are optional) grep needs at least a pattern. In case grep is invoked with no paramters at all it prints usage information like follows
Aufruf: grep [OPTION]... MUSTER [DATEI]...
"grep --help" liefert weitere Informationen.
Where MUSTER is the german word for pattern.
This question already has answers here:
Getting "command not found" error in bash script
(6 answers)
Closed 3 years ago.
I have this shell script
#!/bin/sh
PATHS=( a b c d )
for PATH in ${PATHS[#]}
do
rsync -avziP /home/user/$PATH $SERVER:$server_folder -b --backup-dir=$backup_folder/backup_$date --delete --exclude=.* --log-file=$HOME/rsync.log
done
And I always get this error:
rsync: command not found
What is driving me crazy is that if I delete the for loop, and just run the rsync command, the script works perfectly
PATH is a reserved variable!
It is the variable specifying where to search tools (like rsync)
$ set | grep ^PATH=
PATH=/home/user/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Use another variable name!
This question already has answers here:
Getting "command not found" error in bash script
(6 answers)
Closed 3 years ago.
I have this shell script
#!/bin/sh
PATHS=( a b c d )
for PATH in ${PATHS[#]}
do
rsync -avziP /home/user/$PATH $SERVER:$server_folder -b --backup-dir=$backup_folder/backup_$date --delete --exclude=.* --log-file=$HOME/rsync.log
done
And I always get this error:
rsync: command not found
What is driving me crazy is that if I delete the for loop, and just run the rsync command, the script works perfectly
PATH is a reserved variable!
It is the variable specifying where to search tools (like rsync)
$ set | grep ^PATH=
PATH=/home/user/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Use another variable name!