I am writing a script and I noticed that a certain line of code is constantly being reused.
So I thought why not put it into a variable for ease of use, and when something changes, I only need to change it in one location.
When I do this:
scriptpath="echo -e "\n" && curl -s -u lalala:hihihi ftp://ftp.somewhere.com/folder"
and then use the variable as following:
$SCRIPTPATH/some_script.sh | bash
I get the following error message:
bash: line 2: $'\n': command not found
'function scriptpath { echo -e "\n" && curl -s -u lalala:hihihi ftp://ftp.somewhere.com/folder/$SCRIPTNAME | bash }'
but then i need to give the SCRIPTNAME variable a value when calling forth the scriptpath function
– WingZero Dec 20 '18 at 13:31scriptpath
doesn't look like a path, should it be one? Is there some relation betweenscriptpath
andSCRIPTPATH
?) Please [edit] your question to clarify it (don't just put the clarifications in comments). – ilkkachu Dec 20 '18 at 17:43curl ... | bash
(repeatedly), you may want to consider if it's a safe and sane thing to blindly run code downloaded from the internet. – ilkkachu Dec 20 '18 at 17:44