New bash user here, I'm trying to accomplish something simple but can't seem to figure it out
I want to run a script (curl.sh) using a command line argument that will change every time to supply a new IP to the .sh
So running:
~/Documents$ ./curl.sh 10.0.0.18
Would result in the following being run:
#!/bin/bash
curl 10.0.0.18 blablabla
and then running:
~/Documents$ ./curl.sh 10.0.0.19
Would change the .sh to run:
#!/bin/bash
curl 10.0.0.19 blablabla
I have tried setting variables with this article and arguments using sed in this article but must be getting the syntax wrong
$1in your script to refer to the first command line argument.curl $1 blahblablaWhat do you have in your script now?ip="${1:-10.0.0.18}"will use10.0.0.18if no arguments is provided, or it will use whatever is provided as the ip (you should validate it is an IP). Your call to curl is thencurl "$ip" blablabla