这是我几天以来遇到的一个问题。我想通过做简单的脚本来简化很多工作..但脚本工作不正常。文件夹中的许多文件的Bash + gnuplot脚本
脚本应该做的事:
- 尾3行的文件中指定的目录$ {} FOLDER
- 变化extenstion从.gplt无法比拟的。
- 使用gnuplot函数绘制输出。
所有文件在这些文件夹开始:
set term postscript color
set output "x_101.ps"
plot "-" title "magU" with lines
0 0
5.00501e-06 0.00301606
1.001e-05 0.00603211
...
所以我坚持这一点,一些部分没有工作,这就是为什么我问你们,如果有人可以看看对此:
#!/bin/bash
rename(){
newname = $(basename .gplt)
}
FOLDER=(
~/Dokumenty/mgr/obliczenia_OF/ReConst/H20_ReConst_v1/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/H20_ReConst_v2/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/H20_ReConst_v3/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/H20_ReConst_v4/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/R134_ReConst_v1/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/R134_ReConst_v2/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/R134_ReConst_v3/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/R134_ReConst_v4/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/OM_ReConst_v1/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/OM_ReConst_v2/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/OM_ReConst_v3/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/ReConst/OM_ReConst_v4/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/R134_PecletConst_v1/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/R134_PecletConst_v2/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/R134_PecletConst_v3/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/R134_PecletConst_v4/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/OM_PecletConst_v1/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/OM_PecletConst_v2/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/OM_PecletConst_v3/postProcessing/sets/*
~/Dokumenty/mgr/obliczenia_OF/PeConst/OM_PecletConst_v4/postProcessing/sets/*
)
for file in *; do
tail -n+3 ${file} >> ${file}
done
for ff in *; do
rename ${ff}
done
for f in *; do
gnuplot <<- EOF
set terminal png size 400,250
set output '${f}.png'
set grid
set xlabel 'y' rotate by 360
set ylabel 'U(y)'
plot "${f}" using 2:1 with lines
EOF
done
PS。还有一件事。该文件夹有子文件夹,为什么我用这个:
sets/*
在最后,我担心它可能是错误的。
干杯 jilsu。
'tail -n + 3'给出(包括)行号3的所有行..这是正确的吗? –
那么你想要做的是改变所有'.gplt'文件,使得它们产生一个'.png'而不是一个postscript文件?但是你想保留原始的'.gplt'文件? –