This question already has answers here:
Why start a shell command with a backslash?
(2 answers)
Closed 8 years ago.
I found these command from http://rvm.io/rvm/install
Why do we need \ in the following command?
$\curl -sSL https://get.rvm.io | bash
Short version: This skips replacing "curl" with an alias you might have defined.
A more verbose answer you can find here: \curl ... | bash ... what's the slash for?
Related
I am looking for a way to add arguments to a piped curl script which shall be executed in a fish shell. In my case, this is installation of oh-my-fish via curl.
The command without arguments is:
curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish
But as I want to run this in a non interactive environment, I want to add the arguments --noninteractive and --yes to the downloaded script to get something like
curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish -- --noninteractive --yes
This code is just to express, what I want and does not run.
For bash the equivalent would be
curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | bash -s -- --noninteractive --yes
but I cannot find a way to do this with fish.
Tell fish to source stdin with arguments explicitly:
curl | fish -c 'source - --noninteractive --yes'
The - as the filename stands for stdin, any further arguments to source will be used as the $argv, no -- is necessary.
Alternatively, separate the download and running step:
curl > file
fish file --noninteractive --yes
Fish stops processing its own arguments after the filename so, again, no -- necessary.
Or, for your problem at hand, oh-my-fish reads the variables "NONINTERACTIVE" and "ASSUME_YES", so you can do
curl | NONINTERACTIVE=1 ASSUME_YES=1 fish
This question already has answers here:
Pass args for script when going thru pipe
(3 answers)
Closed 9 months ago.
I have written a shell script to configure a development environment and and retrieving using cURL. The script takes up to 3 flags, -d, -f and -s.
How do I pass the flags to the shell script?
Here is the command to run the bash script:
$ curl -sL https://example.com/setup.sh | bash
Here is my first (failed) attempt to pass flags to the script:
$ curl -sL https://example.com/setup.sh | bash -dfs
bash: -d: invalid option
Can anyone explain how to do this?
Use the -s argument:
curl -sL https://example.com/setup.sh | bash -s -- -dfs
This question already has answers here:
How can I suppress all output from a command using Bash?
(8 answers)
Closed 3 years ago.
I tried docker container rm container-name > /dev/null but this still prints Error: No such container: container-name. I'm trying to silence this error in my bash script.
Send stderr to /dev/null:
docker container rm container-name 2> /dev/null
This question already has answers here:
Why bash alias doesn't work in scripts? [duplicate]
(3 answers)
Closed 4 years ago.
On ubuntu 18.10 I've problem with a simple script.
If I execute this command directly from shell it works:
drush -y rsync #d8.live:web/sites/default/files #self:sites/default --delete -vv
If I create a .sh script with:
#!/bin/bash
drush -y rsync #d8.live:web/sites/default/files #self:sites/default --delete -vv
The script doesn't work and the drush command returns me an error:
The "--delete" option does not exist.
The command and the script are running from the same directory and the same user.
Where is the problem?
PS: "drush" is a wrapper that executes a docker-compose command
[EDIT]
$ type -a drush
drush ha "drush --strict=0" come alias
drush è /usr/local/bin/drush
$ cat /usr/local/bin/drush
#!/bin/bash
cd $PWD
docker-compose -p example exec --user 82 php drush $#
Aliases don't get expanded in scripts. If you want the script to include --strict=0 in the command line, you have to say so explicitly in the script.
As mentioned here:
$ type -a drush
drush ha "drush --strict=0" come alias
drush è /usr/local/bin/drush
the drush command is within your PATH environmental variable.
Now please make sure that /usr/local/bin folder is part of your `PATH variable, e.g. by:
$ tr : "\n" <<<$PATH | grep usr.local.bin
/usr/local/bin
This question already has answers here:
Pass commands as input to another command (su, ssh, sh, etc)
(3 answers)
Why can't I use 'sudo su' within a shell script? How to make a shell script run with sudo automatically
(6 answers)
how to execute multiple commands after sudo command
(2 answers)
Closed 5 years ago.
I have a little bash script to run, but it appears to stop without errors on the second line:
export REQUIRE_TRIGGER=0
sudo -s -H
killall ptpd ntpd
nice -n -19 ptpd -gGW -b eth0 -s2 -i NTP -t -c D
The script is in a file. What am I missing?
try to do
sudo killall ptpd ntpd
sudo nice -n -19 ptpd -gGW -b eth0 -s2 -i NTP -t -c D