I want to execute a command with arguments read from a file. This works fine until 1 of the arguments has a space.
I tried grouping words with quotes and backslashes, but none of them worked.
The functionality that I am is exactly what xargs does, except that I need to call the function, not the command, because it relies on other variables set elsewhere in the script
script:
do_echo() { echo '$1:' $1 echo '$2:' $2 } line=`cat input.txt`
input.txt:
"hello world" "hello back"
Expected Result:
$1: hello world $2: hello back
Observed result:
$1: "hello $2: world"
EDIT:
I use this to execute the same command several times with different inputs. There are up to 15 parameters in a line and can be higher than 50 lines.
A tabular format would be ideal, although the current response to entering each parameter in a row would work.
source share