我想找到Stress_x_vs_Ecutoff_convergence.txt、Stress_y_vs_Ecutoff_convergence.txt和Stress_z_vs_Ecutoff_convergence.txt文件,如果它们存在,请将它们删除。
我尝试创建一个字符串数组来迭代它们。但是编译器告诉我:
i: command not found代码的一部分如下:
components=('x' 'y' 'z')
for i in "${components[@]}"
do
if [ -f "Stress_$(i)_vs_Ecutoff_convergence.txt" ]; then rm "Stress_$i_vs_Ecutoff_convergence.txt"; fi
touch "Stress_$(i)_vs_Ecutoff_convergence.txt"
done我需要变量i来做其他事情,所以如果你尝试给出一个与我的方法没有太大不同的解决方案,我将不胜感激。我知道这可能很简单,但我对bash还不是很熟悉
发布于 2019-07-12 22:56:09
将$(i)更改为${i}。
$(i)表示执行名为"i“的命令。
https://stackoverflow.com/questions/57009413
复制相似问题