Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a better way approach this? 1

Status
Not open for further replies.

vuakhobo

Technical User
Apr 22, 2004
41
0
0
US
I have a very large file that comes to us daily but unfortunately that there is an error and produce quite a bit of reject in the reject.dat file

The error is that there is .n after HH:MM:SS where n could be ANY DIGITS

I used the command below to grep for the parttern where n has 1 digit
grep "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9]" badfile.dat

as for n with 2 digits I repeat the same command but this time after the . it should have two [0-9]

grep "[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9]" badfile.dat

My question is is there a way to grep all regardless how many n's digit there be?
 
grep -E '[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]+' badfile.dat

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top