grep mistaking pattern for file?

cat file.txt | grep -x "\d*"
grep: \Documents and Settings: Is a directory

I want to search file.txt for any lines that are numbers only but grep seems to be viewing \d* as a wildcard for files and not the pattern. How can I specify that it's the pattern and it should use stdin for what to grep over?

The file is full of lines of datetime stamps, some end with a letter, some don't.

20140110122200
20131208041510M
...

I'm trying to only get the lines that don't end in a letter.

EDIT: I've also tried setting the filename instead of piping it with cat. Not much different.

C:\long\path>grep -ex "\d*" -f file.txt
grep: \Dell: Is a directory
grep: \Documents and Settings: Is a directory

Answers


Why are you using cat to pass the file to grep? Why not just give grep the filename directly?

grep -x '\d*' file.txt

I think the actual problem you're seeing is that the * wildcard is being expanded. That's why grep is giving you errors that mention actual directories (beginning with 'd') on your system.


Need Your Help

AdColony proguard error

android proguard ads advertising adcolony

I include AdColony in my android app and now I am trying to export my app with proguard. I found configuration for AdColony here and here. I tried to include them separately and together into progu...

Aptana 3.1.1 - Character encoding

encoding character aptana

I have updated to Aptana 3.1.1 and now my projects writen in ISO-8859-1 show some characters very wrong. There's a workaround, but then my UTF-8 projects gets wrong characters.