使用标准 cmd 行命令从文件中的每一行递归搜索文本
Search recursively text from each line in file using standard cmd line commands
我有一个文件,其中包含 grep
调用准备的变量名称。
现在我想执行以下操作:grep
递归目录并在每个文件中搜索每个变量条目(来自最初准备的文件)。我如何通过 awk/sed 或任何其他控制台实用程序实现它?例如,我知道如何使用 python 脚本,但现在我想使用纯控制台解决方案。
我坚持对数据应用命令:awk '{ print [=12=]}' RS="/" settings_vars.txt
对吗?但是如何调用命令而不是 print
行内容?
您可以将递归 grep 与 -f
选项一起使用:
grep -rHf settings_vars.txt .
使用的选项是:
-f # Read one or more newline separated patterns from file.
-H # Always print filename headers with output lines.
-r # Read all files under each directory, recursively, following symbolic links only
if they are on the command line.
我有一个文件,其中包含 grep
调用准备的变量名称。
现在我想执行以下操作:grep
递归目录并在每个文件中搜索每个变量条目(来自最初准备的文件)。我如何通过 awk/sed 或任何其他控制台实用程序实现它?例如,我知道如何使用 python 脚本,但现在我想使用纯控制台解决方案。
我坚持对数据应用命令:awk '{ print [=12=]}' RS="/" settings_vars.txt
对吗?但是如何调用命令而不是 print
行内容?
您可以将递归 grep 与 -f
选项一起使用:
grep -rHf settings_vars.txt .
使用的选项是:
-f # Read one or more newline separated patterns from file.
-H # Always print filename headers with output lines.
-r # Read all files under each directory, recursively, following symbolic links only
if they are on the command line.