当前位置: 技术问答>linux和unix
[询问]solaris下grep -v命令的使用,不解啊。。。。
来源: 互联网 发布时间:2016-09-14
本文导语: 我想找到当前目录下名为jdk60的文件,但看到了好多“Permission denied”的行,我不想看到类似的行。于是乎,我就是这么写: $ find . -name jdk60 | grep -v "Permission denied" find: cannot read dir ./lost+found: Permission denied find: cann...
我想找到当前目录下名为jdk60的文件,但看到了好多“Permission denied”的行,我不想看到类似的行。于是乎,我就是这么写:
$ find . -name jdk60 | grep -v "Permission denied"
find: cannot read dir ./lost+found: Permission denied
find: cannot read dir ./var/lost+found: Permission denied
find: cannot read dir ./var/sadm/patch/112964-11/: Permission denied
find: cannot read dir ./var/sadm/patch/112874-31/: Permission denied
find: cannot read dir ./var/sadm/patch/113033-05/: Permission denied
find: cannot read dir ./var/sadm/patch/112834-06/: Permission denied
find: cannot read dir ./var/sadm/patch/113277-32/: Permission denied
find: cannot read dir ./var/sadm/patch/112908-17/: Permission denied
find: cannot read dir ./var/sadm/patch/114684-03/: Permission denied
find: cannot read dir ./var/sadm/patch/112925-05/: Permission denied
find: cannot read dir ./var/sadm/patch/112921-06/: Permission denied
find: cannot read dir ./var/sadm/patch/112960-24/: Permission denied
find: cannot read dir ./var/sadm/patch/112911-13/: Permission denied
find: cannot read dir ./var/sadm/patch/115665-10/: Permission denied
find: cannot read dir ./var/sadm/patch/117171-17/: Permission denied
find: cannot read dir ./var/sadm/patch/112817-23/: Permission denied
find: cannot read dir ./var/sadm/patch/116538-03/: Permission denied
find: cannot read dir ./var/sadm/patch/112926-06/: Permission denied
find: cannot read dir ./var/sadm/patch/116105-04/: Permission denied
find: cannot read dir ./var/sadm/patch/117203-05/: Permission denied
find: cannot read dir ./var/sadm/patch/117459-01/: Permission denied
find: cannot read dir ./var/sadm/patch/114503-12/: Permission denied
为什么结果还是这样啊?????
|
$ find . -name jdk60 | grep -v "Permission denied"
因为grep -v "Permission denied"是去标准输出(1)里找信息 而你屏幕上的这些输出是标准错误(2)
下面这样就可以了
$ find . -name jdk60 2>&1| grep -v "Permission denied"
因为grep -v "Permission denied"是去标准输出(1)里找信息 而你屏幕上的这些输出是标准错误(2)
下面这样就可以了
$ find . -name jdk60 2>&1| grep -v "Permission denied"