1

(not sure if this question belongs on superuser or unix.stackexchange, if i'm in the wrong place, please let me know)

as the title says, is grep -r / -e foo going to avoid /dev/urandom /dev/zero /dev/random etc? or is it really going to search through all of /dev/urandom ? (which would take practically forever and yield no interesting results)

1
  • I don't know, grep /dev/random -e "To be or not to be" sounds like it could result in something interesting after some time...
    – Mokubai
    Aug 18, 2021 at 13:06

1 Answer 1

2

grep will dive into infinite data sources such as /dev/urandom or /dev/zero by default. You can prevent this behavior by adding -I. Description from the manual:

-I Process a binary file as if it did not contain matching data; this is equivalent to the --binary-files=without-match option.

2
  • i don't want to skip binary files though, seems another option is --devices=skip
    – hanshenrik
    Aug 18, 2021 at 13:23
  • neither option (neither -I nor --devices=skip) prevents grep -r from getting hung on trying to read /dev/kmsg though =/ it doesn't get to read anything and just hangs on a read()
    – hanshenrik
    Aug 18, 2021 at 14:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .