LMSouq
php-dev Open

Bash script error: "function: not found". Why would this appear?

E
E T
1 month ago
3 views
Problem Description
I'm trying to run a `bash script` on my Ubuntu machine and it is giving me an error: > function not found To test, I created the following script which works fine on my laptop but not on my Desktop. Any ideas as to why? My laptop is a mac if that's relevant. #!/bin/bash function sayIt { echo "hello world" } sayIt This returns "hello world" on my laptop, but on my Desktop it returns: > run.sh: 3: function not found hello world run.sh: 5: Syntax error: > "}" unexpected

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base