使用find命令查找指定目录中的文件,并将其输出转换为here-string。
以下是一个示例脚本:
#!/bin/bash
files=$(find /path/to/dir -name '*.txt' -print0 | tr '\0' ' ')
while read -r line; do
echo $line
done <<< "$files"
此脚本使用find命令查找/path/to/dir中所有扩展名为.txt的文件,并将其输出转换为here-string。然后,使用while循环逐行读取here-string的内容并进行处理。