I typed grep ch->spl[4] * into my shell to look for something in a mud code and its broken grep now. Any time I try to grep anything pretty much it puts the spl[4] before the filename like this.

[:spl[4]:spl[4]:spl[4]:spl[4]:spl[4]:spl[4]:spl[4]:spl[4]:spl[4]:act_wiz.c:           if ( vch->timer > 0 )

Question is how do I clear/stop this so I can get my normal grep back?

  • Did you try reinstalling grep? Use sudo apt-get install --reinstall grep. – jobin Mar 11 '14 at 13:04
  • 7
    It is possible the command has resulted in extra files in your current directory because of the '>' symbol being interpreted as an output redirection operator. What is the output of 'ls' in the current directory? Do you have any files called 'spl[4]' or something similar? – user21322 Mar 11 '14 at 13:06

What does grep ch->spl[4] * do? It will search for the pattern ch- in all files (and directories) in your current directory and save the result in the file spl[4]. To avoid this, you should always quote your grep patterns:

grep "ch->spl[4]" *

Still, the behavior you describe is very strange, there is no reason why this would have changed you your grep works. What is probably happening is that you keep searching through the spl[4] file (because you are grepping *) and that file contains the output you see. Chances are that if you delete it, things will go back to normal.

| improve this answer | |
  • Thanks Terdon that was exactly it. It had created a file called spl[4] and a few other variations. On deleting those it went back to normal. – user257089 Mar 12 '14 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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