I have a script which uses parameters. In the shell I run the script like this: ./script 1 2 3 4
. I prefer to use a file which contain 1 2 3 4 in a single line and run: ./script `cat file`
.
After I call this script in a for loop like this: for i in `./script `cat file` `
but it doesn't work. What is the good syntax?
You cannot nest tilde (command substitution) like this. You can do this bash:
for i in $(./script $(<file))
$(<file)
is another way of getting the output of $(cat file)