I am currently using the below function
!/bin/bash
#Colour change functions
fnHotlinkG2R()
{
sed -i 's/#hotlink {height: 200px;width: 200px;background: green;/#hotlink {height: 200px;width: 200px;background: red;/' /var/www/html/style.css
}
Rather than creating multiple difference functions I would like to enter the #hotlink as different every time I call the function from within the script.
I am fairly new to sh scripts and would like some assistance please.
First, the first line should be hash bang
#!then followed by the path to the program, not just!.In bash, you don’t declare parameter for the function. You just take the argument (and check whether it is valid/not empty) and use it. In this case, you may want to take the first argument from the function by
$1and replace #hotlink with it.In the part where the function is called, you can call it as if it is another command, and you will supply the #hotlink argument to the command.