grep -E is broken -- cannot find end of line
This is driving me crazy. Looking here at Centos 5 but I have experienced this on various occasions, RH9 up to Centos 6.
Code:
grep ,$ /target/path/filename Same problem inside vi editor, yet I have no problem with the ^ anchor in vi or with grep. Anyone have any clues what might cause this? ... Thanks! |
your regex is correct an works for me, dont know if this would matter but are your line endings unix or dos if they are dos that may make a difference.
|
Hi Keith ... thanks for the reply. How do I know if it is DOS? When I save out the file using vi "wq!", it just says the filename, line count, file size and "written". I think it would normally tell me if it was dos. Is there a grep workaround for dos file that I can try? ... Thanks.
|
Hmmm. Now finding similar issues in other posts, but evidently not same exact issue and still not sure if this is DOS file related. I used the file command and it just says: ASCII English file.
I tried grepping for these but also got no hits. ',\r' ',\n' ',\r\n' |
I opened the file with WinVi to view it in hex mode and lines end with 0a -- not 0d0a so I have to guess this is not a DOS file issue. :banghead:
|
Quote:
Try Code:
grep ',[[:space:]]*$' |
I checked and grep works with dos line endings anyway so its not that.
|
Perhaps I am being redundant, but in Vim, I always use the:
Code:
:set list Best regards, HMW |
:) Glad to see its got the seniors here stumped so far too. I'm no guru but I've been around the block a few times and this one just makes no sense at all. Good tips from everyone I was not aware of or forgot to check. Definitely no hidden character or space. I tried the ':set list' trick in vi and gave me this:
Code:
601,601,$ |
Just to be clear, this is what I show in vi when *not* using the :set list
Code:
601,601, Code:
36 30 31 2c 36 30 31 2c 0a |
Does sed work as expected if it too doesn't work then it's probably your file if it does then its probably your grep, try
Code:
sed -n '/,$/p'/path/to/file |
Quote:
Tested and verified with grep 2.6.3 (CentOS 6). I have no problem matching ",$" on files with plain LF line endings. On files with CR/LF line endings, I need to use ",.$" to match lines ending with a comma. And, that's all with or without "-E" and regardless of how the ",$" is or is not quoted in the shell command line. |
Quote:
|
What shell are you using?
|
Quote:
|
All times are GMT -5. The time now is 10:13 AM. |