grep simply fails when used on a few files

Posted by Reid on Super User See other posts from Super User or by Reid
Published on 2011-01-10T19:11:28Z Indexed on 2011/01/10 19:55 UTC
Read the original article Hit count: 340

Filed under:

I've been trying for about the past 30 minutes to get this to work properly. grep is not exactly the most difficult thing to use, so I'm somewhat baffled as to why this won't work.

The files I'm trying to use grep on are simple XHTML log files. Their names are in the format [email protected], though I don't think that should matter, and inside is simple XHTML.

I copied one such log file to be testfile so you can see the output of some commands and why it's baffling to me:

[~/.chatlogs_windows/dec] > whoami
reid
[~/.chatlogs_windows/dec] > type grep
grep is /bin/grep
[~/.chatlogs_windows/dec] > uname -a
Linux reid-pc 2.6.35-22-generic #33-Ubuntu SMP Sun Sep 19 20:32:27 UTC 2010 x86_64 GNU/Linux
[~/.chatlogs_windows/dec] > head -1 /etc/issue
Linux Mint 10 Julia
[~/.chatlogs_windows/dec] > ls -Alh | grep testfile 
-rw-r--r-- 1 reid reid  63K 2011-01-10 12:45 testfile
[~/.chatlogs_windows/dec] > tail -3 testfile 
</body>
</html>
[~/.chatlogs_windows/dec] > file testfile
testfile: XML document text
[~/.chatlogs_windows/dec] > grep html testfile 
[~/.chatlogs_windows/dec] > grep body testfile 
[~/.chatlogs_windows/dec] > grep "</html>" testfile 
[~/.chatlogs_windows/dec] > grep "</body>" testfile
[~/.chatlogs_windows/dec] > cat testfile | grep html
[~/.chatlogs_windows/dec] > cat testfile | wc -l
231
[~/.chatlogs_windows/dec] > cat testfile | tail -3
</body>
</html>
[~/.chatlogs_windows/dec] > chmod a+rw testfile && ls -Alh | grep testfile
-rw-rw-rw- 1 reid reid  63K 2011-01-10 12:45 testfile
[~/.chatlogs_windows/dec] > grep html testfile

That's what I'm attempting to do. I want to just use grep -ri query . in ~/.chatlogs_windows, which normally works perfectly for me... but for some reason, it completely fails at going through these files.

If it matters, I copied these files off of my Windows 7 partition. But I chown'd them and gave myself all the appropriate permissions, and other programs (like cat) seem to read them just fine. I also copied testfile to testfile_unix and converted the line endings and tried that, but it didn't work either.

I'm using zsh, but I tried it on bash and that failed too. Also, grep works normally: I tried it out on my documents folder and it worked flawlessly.

If you need any more information, just let me know. I tried googling around, but I found no reason for grep to simply not work. Thanks in advance.

© Super User or respective owner

Related posts about grep