如何迭代Bash脚本中的位置参数?

我哪里错了?

我有一些文件如下:

filename_tau.txt
filename_xhpl.txt
fiename_fft.txt
filename_PMB_MPI.txt
filename_mpi_tile_io.txt

我将tau,xhpl,fft,mpi_tile_io和PMB_MPI作为脚本的位置参数传递给如下:

./script.sh tau xhpl mpi_tile_io fft PMB_MPI

我想要grep在循环内搜索,首先搜索tau,xhpl等等.

point=$1     #initially points to first parameter
i="0"
while [$i -le 4]
do
  grep "$str" ${filename}${point}.txt
  i=$[$i+1]
  point=$i     #increment count to point to next positional parameter
done
像这样设置你的for循环.使用这种语法,循环遍历位置参数,依次将每个参数分配给“点”.
for point; do
  grep "$str" ${filename}${point}.txt 
done

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...