Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
Did you try reinstalling grep? Use sudo apt-get install --reinstall grep. –  i08in Mar 11 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? –  OrbWeaver Mar 11 at 13:06
add comment

1 Answer 1

up vote 1 down vote accepted

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.

share|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 at 13:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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