1

I have to search in many files with several lines, the lines with a telephone number of exactly ten digits. Examples of the lines:

telephoneNumber: 66727166501

telephoneNumber: 6672716650

telephoneNumber: 66727166

telephoneNumber: 6672716651

So I am expecting the lines:

telephoneNumber: 6672716650

telephoneNumber: 6672716651

I am using the next grep instruction for the search:

grep '^telephoneNumber: [0-9]\{10\}$' file.txt

It works fine in Ubuntu, OpenSuse and Cygwin, but when I run it in Solaris, it does not do the match, if a delete the $ at the end of the pattern, it does match, but is taking it like "at least 10 digits"

Any suggestions?

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • Try using `grep '^telephoneNumber: [0-9]\{10\}[^\d]*' file.txt` on a sample data to see what happens? The output might indicate something. – Jerry May 14 '13 at 17:01
  • Thanks for your help but I finally found the answer, I will tell in a few hours – user2295976 May 14 '13 at 20:43

1 Answers1

0

The cause of the problem was very simple, I did not realize it because, like I said, I was running the command in diferent distributions with no problem (I do not know why) and also I was not cheking the files with the option in the text editor

The problem was the EOL of the files to apply the search, the originals files did not have the Unix format, regrettably, the creation of these files are not under my control