0

I define two functions in a bash script say.sh. I would like ./say.sh hello calls hello(), and ./say.sh hi calls hi(). What is the bash-y way to do it?

#!/bin/bash

hello(){
    echo "hello"
}


hi(){
    echo "hi"
}
zell
  • 9,830
  • 10
  • 62
  • 115
  • `$1` should call the function that is given as first parameter. – 0stone0 Mar 17 '21 at 14:05
  • [Try it online!](https://tio.run/##XYkxDoAgEMD2e8WJDjoR3@BLAFEuQTAIJsb49pM42q2tVodjbhupKUhdBcBZ72M/3IAVa1xE8SUBD9RLv0Vfb3FS3uNSgskUA@4pnjTbGfWFC6Ujo0pr2WzI0I3M7OgF "Bash – Try It Online") – 0stone0 Mar 17 '21 at 14:07
  • 1
    I like you link, @0stone0. – zell Mar 17 '21 at 15:00

0 Answers0