I have a file (commands
) containing a list of commands to be executed with one command per line. I need to parse each line with my bash script (main.sh
) to maintain the parameters intact, so that I can pass them to another bash script (helper.sh
).
For example:
If commands
contains:
echo -e "hello world\n"
cat path_to/some\ file
...
I need main.sh
to be able to distinguish the parameters in each line as a bash script normally would (desired results):
for line 1:
command: echo
$1: -e
$2: hello world
for line 2:
command: cat
$1: path_to/some file
So that I can store them in an array and pass them to helper.sh
properly.
So far, I've ended up with something like (current results):
for line 1:
command: echo
$1: -e
$2: "hello
$3: world
"
for line 2:
command: cat
$1: path_to/some\
$2: file