Bash/MLT:如何从文件加载字符串并传递给 melt 参数

Bash/MLT : how to load string from file and passing to melt argument

我需要执行以下命令:

melt color:"#eeeeee"  -filter dynamictext:"this text"

"this text" 是来自 title.txt 文件的字符串。

我用这个方法读取文件:

while IFS='' read -r line || [[ -n "$line" ]]; do
     echo $line 
done < "title.txt"

问题是如何让bash中的-filter dynamictext:"this text"作为字符串循环,最后执行:

melt color:"#eeeeee" $string

我使用了这段代码,但到目前为止运气不好:

while IFS='' read -r line || [[ -n "$line" ]]; do
   string="$string -filter dynamictext:\"$line\""
done < "title.txt"

熔化错误:Failed to load "text"

title.txt 包含:

this text
second text
anothe text

使用数组;这是他们被引入处理的确切用例。

while IFS= read -r line; do
    options+=(-filter dynamictext:"$line")
done < title.txt
melt color:#eeeeee "${options[@]}"

修复 title.txt,使其正确地以换行符结尾。