使用文件中的正则表达式字符串在另一个文件中进行搜索
use regex string from a file to do a search in another file
我想使用正则表达式 stringA grep fileA 中的内容。由于这个 stringA 太长(一些 id),所以我将它们放入一个文件中 |分隔。例如,
12345|34567|98765|78657
现在如何在不从 stringA 文件复制正则表达式字符串的情况下执行 grep。这是不可能的,因为有将近 40k。
cat 文件A | egrep stringA.file > thisIdsStuff
谢谢
是,使用egrep -f your_regex.file file_to_be_search > search.result
In man egrep
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)
我想使用正则表达式 stringA grep fileA 中的内容。由于这个 stringA 太长(一些 id),所以我将它们放入一个文件中 |分隔。例如,
12345|34567|98765|78657
现在如何在不从 stringA 文件复制正则表达式字符串的情况下执行 grep。这是不可能的,因为有将近 40k。
cat 文件A | egrep stringA.file > thisIdsStuff
谢谢
是,使用egrep -f your_regex.file file_to_be_search > search.result
In man egrep
-f FILE, --file=FILE
Obtain patterns from FILE, one per line. The empty file contains zero patterns, and therefore matches nothing. (-f is specified by POSIX.)