Search code examples
bashshellreplit

How do I open a file from a folder in bash?


I am using Bash on repl.it. I am making my own command line, and I would like to know how to run a script from a folder called commands. Basically, I would like to make a file run from a folder. How can I do this?

A picture describing what I want to do

Link to my repl


Solution

  • Could you just run it like this?

    sh commands/${input}.sh
    

    Also you should be able to push/pop dir to go into/out of directories.

    pushd commands
    # adds cwd into a stack and goes to <dir> commands/
    sh $input.sh
    popd 
    # goes back to last dir in stack.