TL;DR How can I split a line into an array?
I have a file
cmd1 arga ... argm count
cmd2 arga ... argn count
cmd1 arga ... argm count
cmd1 arga ... argj count
cmd4 arga ... argk count
cmd2 arga ... argn count
where each line contains a command name, a variable number of arguments and a count number.
I’m writing a Bash script that reads a line from said file, via stdin, processes the arguments and invokes $count
times the command, like
while : ; do
IFS= read line
???
for n in $(seq $count) ; do
$cmd $(funabc $a $b $c) $(funrest $c ... $last)
done
done
I guess that I have to use an array (so maybe it’s a a XY problem..), but I don’t know how to go from $line
to an array.