Hi gusy I am trying to learn Bash and cannot seem to get this basic script to work.
#!/bin/bash
function system_info
{
echo "function system_info"
}
$(system_info)
I get a function: command not found issue.
Any help much appreciated
Hi gusy I am trying to learn Bash and cannot seem to get this basic script to work.
#!/bin/bash
function system_info
{
echo "function system_info"
}
$(system_info)
I get a function: command not found issue.
Any help much appreciated
Invoke the function inside the script with just the function name and execute the script from the shell
Kind of redundant but it works without the command not found error.
Or This:
If you want to use newline character.
You can try this code in: https://www.tutorialspoint.com/execute_bash_online.php
Bash is trying to evaluate the string that is outputted by the
system_info
function. You'll want to try the following, which will just simply run the function:or to store the outputted value to a variable:
You need to invoke the function by saying:
$(...)
is used for command substitution.