遍历某个目录下所有文件 #!/bin/bash for file in $folder/* do echo $file done 遍历某个目录下所有 txt 文件 #!/bin/bash for file in $folder/*.txt do echo $file done 文件读取 #!/bin/bash # 方式1 cat "$filepath" | while read line do echo $line done # 方式2 while read line do echo $line done < "$filepath"