"
我想在bash中执行以下命令行
gnuplot -e "filename='data.dat'" plot.gnuplot
我尝试用bash脚本将其包装如下:
#!/bin/bash # -*- coding: utf-8 -*- gnuplot -e "filename=\'${1}\'" plot.gnuplot
bash -x plot.sh data.dat
但它表明:
+ gnuplot -e 'filename=\'\''data.dat\'\''' plot.gnuplot filename=\'data.dat\' ^ line 0: invalid character \
怎么做?
尝试在命令之前设置变量:
path="filename='${1}'" gnuplot -e "$path" plot.gnuplot
如果需要在变量周围加引号:
path="\"filename='${1}'\"" gnuplot -e "$path" plot.gnuplot
gnuplot -e "\"filename='${1}'\"" plot.gnuplot