Currently trying to write a looping case script that matches different cases to execute scripts. However, I am unsure as off how to pass arguments into the cases after the cases have been matched! This is what I have but does not work. I am new to bash so thanks for any help in advance!
Edit:
I have changed to ${@:2} but when I enter delete text.txt or open x, I get Error returned. I think the program is unable to read the rest of the input.
I run the looping script in the command line -
./loop.sh
I then type
open John
The script open.sh runs to make a new directory with the name of the following argument. It works manually - I type ./open.sh John and a directory named John is created. Here I wish to type open John which enters the loop, matches the open case and then puts John after the command to run the script and make the directory.
If I type ./loop.sh
Then open it does match it. But cannot run the script because the script requires an argument
#!/bin/bash
while true; do
read request
case $request in
open)
./open.sh "${@:2}"
;;
delete)
./delete.sh "${@:2}"
;;
*)
echo "Error"
exit 1
esac
done