本题是上一题的方向延伸。我的搜索要求如下
需要搜索的多个字符串存储在文件 values.txt(输入文件)中,例如包含如下信息
string1 1
string2 3
string3 5
- 其中第一列 (string1, string2, string3) 表示需要搜索的字符串,而第二列表示要搜索的出现次数。
- 此外,需要对具有特定文件扩展名(例如 .out、.txt 等)的文件进行递归搜索
- 搜索输出应定向到一个文件,其中搜索的输出与文件名及其路径一起打印。
例如,典型输出必须如下所示(用于递归搜索扩展名为 .out 的文件名)
<path_of_searched_file1/fileName1.out>
The full line containing the <first> instance of <string1>
The full line containing the <first> instance of <string2>
The full line containing the <second> instance of <string2>
The full line containing the <third> instance of <string2>
The full line containing the <first> instance of <string3>
The full line containing the <second> instance of <string3>
The full line containing the <third> instance of <string3>
The full line containing the <fourth> instance of <string3>
The full line containing the <fifth> instance of <string3>
<path_of_searched_file2/fileName2.out>
The full line containing the <first> instance of <string1>
The full line containing the <first> instance of <string2>
The full line containing the <second> instance of <string2>
The full line containing the <third> instance of <string2>
The full line containing the <first> instance of <string3>
The full line containing the <second> instance of <string3>
The full line containing the <third> instance of <string3>
The full line containing the <fourth> instance of <string3>
The full line containing the <fifth> instance of <string3>
and so on
使用 awk 是解决此搜索问题的最佳方法吗?如果是这样,有人可以帮助我修改上一个问题中提供的 awk 代码以满足我当前的搜索要求。