命令替换所有 *.gpl 文件的特定内容
command to replace specific contents of all *.gpl files
我的 *.gpl
文件中有下面这行。
#WANTS TO MODIFY REFERENCE_OUTPUT_* HERE IN BELOW LINES
set output "REFERENCE_OUTPUT_fun1.png"
set output "REFERENCE_OUTPUT_fun2.png"
set output "REFERENCE_OUTPUT_fun3.png"
set output "REFERENCE_OUTPUT_fun4.png"
-
-
-
#DO NOT WANTS TO MODIFY REFERENCE_OUTPUT_* FOR BELOW LINE
plot '/project/subfolder1/REFERENCE_OUTPUT_fun1.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red"
我在转储文件夹中至少有 800+ *.gpl
个文件。
我想将生成的输出 png
文件转储到单独的 images
文件夹中。
所以,
我正在尝试执行以下命令:
sed -i 's/set output "REFERENCE_OUTPUT_*/set output "./images/REFERENCE_OUTPUT_*/g' {} *.gpl
但低于错误
错误:
sed: -e expression #1, char 25: unknown option to `s'
预期输出:
在所有 *.gpl
文件中,上面设置的输出行从 :
set output "REFERENCE_OUTPUT_fun1.png"
到
set output "./images/REFERENCE_OUTPUT_fun1.png"
更新:
*.gpl
文件还有 :
plot '/project/subfolder1/REFERENCE_OUTPUT_fun1.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red"
所以在上面的行 REFERENCE_OUTPUT_fun1.txt
中也有我不想更改的名称 REFERENCE_OUTPUT_fun1
。所以这就是我使用 set output "REFERENCE_OUTPUT_*
的原因,它只会修改此 set output . .
行(理论上)
您不需要匹配整个字符串 - 只需替换前缀
sed -E -i -u 's/(REFERENCE[a-zA-Z_0-9]+\.png)/\.\/images\//g' *.gpl
我的 *.gpl
文件中有下面这行。
#WANTS TO MODIFY REFERENCE_OUTPUT_* HERE IN BELOW LINES
set output "REFERENCE_OUTPUT_fun1.png"
set output "REFERENCE_OUTPUT_fun2.png"
set output "REFERENCE_OUTPUT_fun3.png"
set output "REFERENCE_OUTPUT_fun4.png"
-
-
-
#DO NOT WANTS TO MODIFY REFERENCE_OUTPUT_* FOR BELOW LINE
plot '/project/subfolder1/REFERENCE_OUTPUT_fun1.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red"
我在转储文件夹中至少有 800+ *.gpl
个文件。
我想将生成的输出 png
文件转储到单独的 images
文件夹中。
所以,
我正在尝试执行以下命令:
sed -i 's/set output "REFERENCE_OUTPUT_*/set output "./images/REFERENCE_OUTPUT_*/g' {} *.gpl
但低于错误
错误:
sed: -e expression #1, char 25: unknown option to `s'
预期输出:
在所有 *.gpl
文件中,上面设置的输出行从 :
set output "REFERENCE_OUTPUT_fun1.png"
到
set output "./images/REFERENCE_OUTPUT_fun1.png"
更新:
*.gpl
文件还有 :
plot '/project/subfolder1/REFERENCE_OUTPUT_fun1.txt' u 1:2 w l axes x1y1 ti "Ref output" lc rgb "red"
所以在上面的行 REFERENCE_OUTPUT_fun1.txt
中也有我不想更改的名称 REFERENCE_OUTPUT_fun1
。所以这就是我使用 set output "REFERENCE_OUTPUT_*
的原因,它只会修改此 set output . .
行(理论上)
您不需要匹配整个字符串 - 只需替换前缀
sed -E -i -u 's/(REFERENCE[a-zA-Z_0-9]+\.png)/\.\/images\//g' *.gpl