Unix RedHat - 无法在 "find" 命令中排除 "Permission denied" 消息
Unix RedHat - Can't exclude "Permission denied" message on "find" command
我在 RedHat unix 服务器上工作,我需要 运行 一个 'find' 命令来搜索一些文本文件,但是 'find' return "Permission denied" 对于某些目录。
我在此处的堆栈溢出上搜索了其他类似的帖子,但没有一个给定的答案解决了我的问题。
这是命令我运行:
find . -name "*file_name*20200310*"
这些是我试过但没有成功的选项:
find . -name "*file_name*20200310*" -type f
find . -name "*file_name*20200310*" 2>/dev/null
find . -name "*file_name*20200310*" | grep -v "Permission denied"
find . -name "*file_name*20200310*" -nowarn # really, this option '-nowarn' is about
警告
我查阅了 查找 手册 (unix 'man') 但没有找到解决方案。
拜托,任何人都可以帮助我吗?
提前致谢。
麦酒。
… these are the option I tried without success:
…
find . -name "*file_name*20200310*" 2>/dev/null
…
I'm on /usr/bin/csh
重定向标准错误流的 2>
不被 csh
理解。
要跳过不可读目录的内容,我们可以使用测试
-readable
Matches files which are readable. …
和行动
-prune True; if the file is a directory, do not descend into it. …
相关:
find . \! -readable -prune , -name "*file_name*20200310*"
我通过输入 ksh
shell 并在行尾使用 2>/dev/null
找到了一个解决方案。
这不是真正的解决方案,但现在是我能做的第一件事。
… these are the option I tried without success:
…
find . -name "*file_name*20200310*" | grep -v "Permission denied"
…
I'm on /usr/bin/csh
为了与 csh
一起工作,我们必须使用管道运算符 |&
,它也重定向 stderr
:
find . -name "*file_name*20200310*" |& grep -v "Permission denied"
我在 RedHat unix 服务器上工作,我需要 运行 一个 'find' 命令来搜索一些文本文件,但是 'find' return "Permission denied" 对于某些目录。
我在此处的堆栈溢出上搜索了其他类似的帖子,但没有一个给定的答案解决了我的问题。
这是命令我运行:
find . -name "*file_name*20200310*"
这些是我试过但没有成功的选项:
find . -name "*file_name*20200310*" -type f
find . -name "*file_name*20200310*" 2>/dev/null
find . -name "*file_name*20200310*" | grep -v "Permission denied"
find . -name "*file_name*20200310*" -nowarn # really, this option '-nowarn' is about
警告
我查阅了 查找 手册 (unix 'man') 但没有找到解决方案。
拜托,任何人都可以帮助我吗? 提前致谢。
麦酒。
… these are the option I tried without success:
… find . -name "*file_name*20200310*" 2>/dev/null …
I'm on /usr/bin/csh
重定向标准错误流的 2>
不被 csh
理解。
要跳过不可读目录的内容,我们可以使用测试
-readable
Matches files which are readable. …
和行动
-prune True; if the file is a directory, do not descend into it. …
相关:
find . \! -readable -prune , -name "*file_name*20200310*"
我通过输入 ksh
shell 并在行尾使用 2>/dev/null
找到了一个解决方案。
这不是真正的解决方案,但现在是我能做的第一件事。
… these are the option I tried without success:
… find . -name "*file_name*20200310*" | grep -v "Permission denied" …
I'm on /usr/bin/csh
为了与 csh
一起工作,我们必须使用管道运算符 |&
,它也重定向 stderr
:
find . -name "*file_name*20200310*" |& grep -v "Permission denied"