grep -v 不排除字符串

grep -v 不排除字符串

我试图通过删除带有某些不需要的单词的字符串来缩小要捕获的标志的范围,所以我使用

cat $(find / -size 33c -group bandit6 -user bandit7) | grep -v 'Permission'

但我的结果最终是

find: ‘/cgroup2/csessions’: Permission denied
find: ‘/home/bandit28-git’: Permission denied
find: ‘/home/bandit30-git’: Permission denied
find: ‘/home/bandit31-git’: Permission denied
find: ‘/home/bandit5/inhere’: Permission denied
find: ‘/home/bandit27-git’: Permission denied
find: ‘/home/bandit29-git’: Permission denied
find: ‘/tmp’: Permission denied
find: ‘/lost+found’: Permission denied
find: ‘/root’: Permission denied
find: ‘/etc/ssl/private’: Permission denied
find: ‘/etc/lvm/backup’: Permission denied
find: ‘/etc/lvm/archive’: Permission denied
find: ‘/etc/polkit-1/localauthority’: Permission denied
find: ‘/sys/fs/pstore’: Permission denied
find: ‘/proc/tty/driver’: Permission denied
find: ‘/proc/24068/task/24068/fd/6’: No such file or directory
find: ‘/proc/24068/task/24068/fdinfo/6’: No such file or directory
find: ‘/proc/24068/fd/5’: No such file or directory
find: ‘/proc/24068/fdinfo/5’: No such file or directory
find: ‘/boot/lost+found’: Permission denied
HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

当我想要的只是

HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

`

答案1

所以这似乎$()是问题所在

cat $(find / -size 33c -group bandit6 -user bandit7) 2>/dev/null

但是行不通

cat $(find / -size 33c -group bandit6 -user bandit7 2>/dev/null)

我想grep -v也可以与括号内的 stderr 混合使用

相关内容