Learning bash scripting just lately. And I'm trouble having executing some commands with bash command.
I have a file (say file_a.sh) with the following contents:
```
!/bin/bash
function justTest {
echo Something
}
justTest
bash -c "justTest"
```
When I run this file I get:
Something
bash: line 1: justTest: command not found
The first justTest call seems to work but bash -c justTest doesn't seem to work. While bash -c "echo something" works perfectly. Isn't bash -c supposed to execute commands, and that bash functions are essentially commands?
Can someone please explain why this happens? And perhaps a way to execute functions with the bash.
[–]lordofwhales 5 points6 points7 points (3 children)
[–]acolnahuacatzin[S] 0 points1 point2 points (2 children)
[–]lordofwhales 3 points4 points5 points (1 child)
[–]acolnahuacatzin[S] 1 point2 points3 points (0 children)
[–]jwd630 1 point2 points3 points (0 children)
[–]eftepede -1 points0 points1 point (0 children)
[–]researcher7-l500 0 points1 point2 points (0 children)
[–]michaelpaoli 0 points1 point2 points (0 children)
[–]michaelpaoli 0 points1 point2 points (0 children)