Using bash i'm trying to grep a string coming from /dev/urandom something like this:
tr -cd '[:lower:]' < /dev/urandom | grep -o 'test'
Also tried:
tr -cd '[:lower:]' < /dev/urandom | grep -o 'test' | head -1
I guess grep
keeps waiting for tr
to finish, because even redirecting the output to a file like > /tmp/testfile
nothing is written to the file.
However if parsed to head
before grep
, it works
tr -cd '[:lower:]' < /dev/urandom | head -c 10000 | grep -o 'test'
Is there a way to make it work while stdin is still running?, and if not, why is this behavior from grep
, not to give an output if input hasn't finished?
grep -o
able to search through lines of infinite length could probably be implemented with pcre2partial, but I'm not aware of any grep-like tool making use of that.