I am working on a shell script, and I have several lines of code that are duplicated (copy, say).
I want these lines to be in a function. What is the correct syntax?
And what shoud changes do I make so that these functions can receive parameters?
Here is an example.
I need to enable this:
amount=1 echo "The value is $amount" amount=2 echo "The value is $amount"
In something like this:
function display_value($amount) { echo "The value is $amount" } amount=1 display_value($amount) amount=2 display_value($amount)
This is just an example, but I think it is clear enough.
Thanks in advance.
source share