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.
Related
This question already has answers here:
print the output of strace command in a text file
(1 answer)
How to redirect and append both standard output and standard error to a file with Bash
(8 answers)
Closed 1 year ago.
I am trying to send all printed output of a strace command to a file. straces have a lot of console output since they print all the system calls of a command.
I have tried the most popular ways that I can find or think of, such as command > file.txt which does print output but then the output is not written to a file, same with command | tee file.txt Output is always printed but never written to a file. Is it because there is too much output or something? The first command definitely suceeds.
But my real question is what is the best way to do this and how can I get it done?
Many many thanks,
Milan
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
This question already has answers here:
How to read a file into a variable in shell?
(9 answers)
Difference between sh and Bash
(11 answers)
Closed 4 years ago.
I have store ip address with port in a file and I want to read it using shell script. Thus file serverIP has data 192.168.1.17:3000. I am using following bash script to read it
IPAddressFile=/home/geo/serverIP
SERVER_IP_PORT=$(<$IPAddressFile)
echo $SERVER_IP_PORT
But this script echo empty string. Where I am making mistake?
If you're going to use bash-only syntax like $(<...), your script must be run with bash, not sh.
Thus, either run bash yourscript or add a #!/bin/bash (or similar) shebang, flag the file executable, and invoke it as a command, for example ./yourscript
As an alternative that's both efficient and compatible with POSIX sh:
IFS= read -r SERVER_IP_PORT <"$IPAddressFile"
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 output of system() calls in Ruby
(18 answers)
Closed 8 years ago.
I would like to run a shell script from my ruby file. Then capture its output and analyze it.
This is the scenario:
- Within my ruby script I need to execute the my_script.sh
- The shell script produce the followinf output in the terminal
> my_script.sh
xxxxx 1111
yyyyy 2222
zzzzz 3333
I need to capture and analyse this ouput inside the ruby script in order to find if a keyword is displayed (e.g., yyyy).
I'm using the following comand:
my_script = "/home/script.sh"
system("sh #{my_script}")
I'm not able to capture the output produced in the terminal for parsing
Don't use system, it does not capture STDOUT. Use backticks (or %x()):
output = %x( #{my_script} )