1

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?

MACE
  • 311
  • 4
  • 12
  • 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 – Jaromanda X Mar 04 '20 at 02: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 04 '20 at 03:31
  • Sorry. I didn't realize the formatting of the question was off. I've edited the question. – MACE Mar 04 '20 at 14:05
  • @JaromandaX I have a Zero WH. Three other Zeros are working fine. – MACE Mar 04 '20 at 14:07
  • Is this the same Zero WH that's giving the DHCP problem? If so, have you re-flashed the SD card? – Seamus Mar 05 '20 at 00:56
  • 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 05 '20 at 12:13
  • 2
    Use grep hello test.txt. – Ingo Mar 05 '20 at 19:07
  • @MACE: Happy to hear you're squared away for now. This is just a guess, but new SD cards and re-flashed SD cards may cure 20% of all questions on this site. Also note @Ingo's comment above... he's a smart guy; know that grep is perfectly capable of processing a file - you don't have to "feed" grep through a pipe. See man grep from the CLI :) – Seamus Mar 05 '20 at 20:02

2 Answers2

1

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.

Greenonline
  • 2,740
  • 4
  • 23
  • 36
TuxmAL
  • 21
  • 3
0

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

MACE
  • 311
  • 4
  • 12