Skip to content
Advertisement

Use bash -s with other arguments

I have install.sh script which is located in server. I want to write one line code to download and run the script.

curl -s https://my-server/install.sh | bash

Everything works fine until I am trying to set arguments

curl -s https://my-server/install.sh | bash -s -p abc

It can’t recognize ‘-p’ as an argument but ‘abc’ can.

How to set arguments in this situation starting with ‘-‘ or ‘–‘ signs?

Advertisement

Answer

Start your argument list after -- separator:

curl -s https://my-server/install.sh | bash -s -- -p abc

As per man bash:

A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments. An argument of - is equivalent to --.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement