【问题标题】:Bash/MLT : how to load string from file and passing to melt argumentBash/MLT:如何从文件中加载字符串并传递给熔化参数
【发布时间】:2016-10-06 03:26:51
【问题描述】:

我需要执行以下命令:

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

【问题讨论】:

  • 转义引用:"$string -filter dynamictext:\"$line\""
  • 谢谢,但不起作用..视频输出:“这并生成错误无法加载“文本””
  • "-filter dynamictext:'$line'" 有效吗? (外面用双引号,里面用单引号。)
  • 不工作,视频输出:'这个,控制台错误:无法加载“文本”

标签: bash mlt melt-framework


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-10
    • 1970-01-01
    • 2013-10-27
    • 2016-09-15
    • 1970-01-01
    • 2011-06-29
    • 2021-06-25
    相关资源
    最近更新 更多