在bash中,如何查找存在的文件;测试“;输入字符串,排除二进制文件
在bash中,如何查找存在的文件;测试“;输入字符串,排除二进制文件,bash,shell,awk,grep,find,Bash,Shell,Awk,Grep,Find,find-键入f | xargs grep string | awk-f:“{print$1}”| uniq 在上面的命令中,它获取包含字符串“test”的所有文件的名称。但结果包括 二进制文件 问题是如何排除二进制文件 谢谢大家。如果我理解正确,您希望获取目录及其子目录中包含字符串字符串的所有文件的名称,不包括二进制文件 在阅读grep的友好手册时,我发现: -I Process a binary file as if it did not contain matching da
find-键入f | xargs grep string | awk-f:“{print$1}”| uniq
在上面的命令中,它获取包含字符串“test”的所有文件的名称。但结果包括
二进制文件
问题是如何排除二进制文件
谢谢大家。如果我理解正确,您希望获取目录及其子目录中包含字符串
字符串
的所有文件的名称,不包括二进制文件
在阅读grep的友好手册时,我发现:
-I Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option.
太棒了
现在,我如何摆脱查找。只有grep
,这可能吗?哦,下面两行,仍然在时髦的手册中,我读到:
-R, -r, --recursive
Read all files under each directory, recursively; this is
equivalent to the -d recurse option.
看起来不错,不是吗
只获取文件名怎么样?我还在grep
的有趣手册中读到:
-l, --files-with-matches
Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The
scanning will stop on the first match. (-l is specified by
POSIX.)
耶!我想我们完成了:
grep -IlR 'string' .
备注。
- 我还试图在手册中找到
给我做三明治
,但我的grep
版本似乎不支持它。YMMV
- 本手册位于
man grep
- 正如William Pursell正确评论的那样,
-R
和-I
开关在grep
的所有实现中都不可用。如果您的grep
拥有makeme a sandwich
选项,它很可能支持-R
和-I
开关。YMMV
如果我理解正确,您希望获取目录及其子目录中包含字符串字符串
的所有文件的名称,不包括二进制文件
在阅读grep的友好手册时,我发现:
-I Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option.
太棒了
现在,我如何摆脱查找。只有grep
,这可能吗?哦,下面两行,仍然在时髦的手册中,我读到:
-R, -r, --recursive
Read all files under each directory, recursively; this is
equivalent to the -d recurse option.
看起来不错,不是吗
只获取文件名怎么样?我还在grep
的有趣手册中读到:
-l, --files-with-matches
Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The
scanning will stop on the first match. (-l is specified by
POSIX.)
耶!我想我们完成了:
grep -IlR 'string' .
备注。
- 我还试图在手册中找到
给我做三明治
,但我的grep
版本似乎不支持它。YMMV
- 本手册位于
man grep
- 正如William Pursell正确评论的那样,
-R
和-I
开关在grep
的所有实现中都不可用。如果您的grep
拥有makeme a sandwich
选项,它很可能支持-R
和-I
开关。YMMV
如果我理解正确,您希望获取目录及其子目录中包含字符串字符串
的所有文件的名称,不包括二进制文件
在阅读grep的友好手册时,我发现:
-I Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option.
太棒了
现在,我如何摆脱查找。只有grep
,这可能吗?哦,下面两行,仍然在时髦的手册中,我读到:
-R, -r, --recursive
Read all files under each directory, recursively; this is
equivalent to the -d recurse option.
看起来不错,不是吗
只获取文件名怎么样?我还在grep
的有趣手册中读到:
-l, --files-with-matches
Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The
scanning will stop on the first match. (-l is specified by
POSIX.)
耶!我想我们完成了:
grep -IlR 'string' .
备注。
- 我还试图在手册中找到
给我做三明治
,但我的grep
版本似乎不支持它。YMMV
- 本手册位于
man grep
- 正如William Pursell正确评论的那样,
-R
和-I
开关在grep
的所有实现中都不可用。如果您的grep
拥有makeme a sandwich
选项,它很可能支持-R
和-I
开关。YMMV
如果我理解正确,您希望获取目录及其子目录中包含字符串字符串
的所有文件的名称,不包括二进制文件
在阅读grep的友好手册时,我发现:
-I Process a binary file as if it did not contain matching data;
this is equivalent to the --binary-files=without-match option.
太棒了
现在,我如何摆脱查找。只有grep
,这可能吗?哦,下面两行,仍然在时髦的手册中,我读到:
-R, -r, --recursive
Read all files under each directory, recursively; this is
equivalent to the -d recurse option.
看起来不错,不是吗
只获取文件名怎么样?我还在grep
的有趣手册中读到:
-l, --files-with-matches
Suppress normal output; instead print the name of each input
file from which output would normally have been printed. The
scanning will stop on the first match. (-l is specified by
POSIX.)
耶!我想我们完成了:
grep -IlR 'string' .
备注。
- 我还试图在手册中找到
给我做三明治
,但我的grep
版本似乎不支持它。YMMV
- 本手册位于
man grep
- 正如William Pursell正确评论的那样,
-R
和-I
开关在grep
的所有实现中都不可用。如果您的grep
拥有makeme a sandwich
选项,它很可能支持-R
和-I
开关。YMMV
我使用的Unix版本不支持命令“grep-I/R”
我试过命令:
file `find ./` | grep text | cut -d: -f1 | xargs grep "test"
我使用的Unix版本不支持命令“grep-I/R”
我试过命令:
file `find ./` | grep text | cut -d: -f1 | xargs grep "test"
我使用的Unix版本不支持命令“grep-I/R”
我试过命令:
file `find ./` | grep text | cut -d: -f1 | xargs grep "test"
我使用的Unix版本不支持命令“grep-I/R”
我试过命令:
file `find ./` | grep text | cut -d: -f1 | xargs grep "test"
请注意,-I
和-R
是在grep
的所有实现中都不可用的非标准选项。谢谢!这很有帮助。你的回答很好,给出了每一个细节。顺便问一下,“给我做个三明治”是什么意思?我在谷歌上搜索了“YMMV”,但找不到“给我做个三明治”。对不起,英语不是我的母语请注意,-I
和-R
是非标准选项,并非在所有实现中都可用