Suddenly, grep has begun failing.

cat test.txt | grep hello

generates an "Illegal instruction" error. It makes no difference what's being piped in nor what PATTERN I use.

  • cat test.txt | less
  • grep
  • grep -V
  • grep --help

all work fine

I've done a update and upgrade. How do I fix this?

  • 1
    cat test.txt | less grep that won't run - so, what is the output of grep -V - also which Rpi do you have. I have no issue with grep in Rpi3/4 - but I've had issues with other programs in RPi1 with illegal instruction error that doesn't occur in Rpi3/4 Mar 4, 2020 at 2:08
  • 1
    @MACE surely you mean cat test.txt | less grep is the command which doesn't work, and cat test.txt | grep hello is one of the ones which "work fine"?
    – justinjt
    Mar 4, 2020 at 3:31
  • Sorry. I didn't realize the formatting of the question was off. I've edited the question.
    – MACE
    Mar 4, 2020 at 14:05
  • 1
    @Seamus, yes, it's the same device. I did end up flashing the SD and all the issues are gone. I was hoping for a less dramatic option.
    – MACE
    Mar 5, 2020 at 12:13
  • 2
    Use grep hello test.txt.
    – Ingo
    Mar 5, 2020 at 19:07

2 Answers 2


I got the same "illegal instruction" doing some other operation on my RPi 2B, but also some corrupted files on the micro SD card. While fiddling with these problems, I spotted many "Under-voltage" error in system log (see sudo journalctl)and a red LED glowing that I didn't noticed earlier.

So I replaced my power supply that did well for years with my old RPi mod B and all errors went away.


SD card got corrupted. Recreated and all works fine. Not sure how to prevent it in the future. Possibly related to the power.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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