-1

im trying to narrow down a flag to catch by removing strings with certain unwanted words so i use

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

but my results end up being

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

when all i want is

HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs

`

marked as duplicate by Jeff Schaller, roaima, mosvy, Fabby, George Vasiliou Dec 28 '18 at 23:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • it does appear to be and issue with stderr but neither 2>&1 or any use of /dev/null seem to resolve this – ghostpunk Dec 28 '18 at 19:34
  • yeh still 2>/dev/null has no affect – ghostpunk Dec 28 '18 at 19:42
  • where'd you put it? It needs to relate to the find command: find / -size 33c -group bandit6 -user bandit7 2>/dev/null – Jeff Schaller Dec 28 '18 at 19:42
  • solved it is because 2>/dev/null was not inside $(should be in here) – ghostpunk Dec 28 '18 at 19:52
0

so it appears to $() was the problem

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

will not work, however

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

will work i imagine grep -v may work with some mixture of stderr inside the brackets aswell

  • If you explain why the first command does not work and the second command does the job, your answer will get some upvotes. – George Vasiliou Dec 28 '18 at 23:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.