Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Hi All, Can you please let me know how to grep for a
particular pattern in unix. I want to print the dates from
the file exp.txt. the date pattern is DD:MM:YYYY, I just
want to print all the dates from the file exp.txt.

Answer Posted / venkat

grep -o -P '(([0-2][0-9]|3[01]):([0][1-9]|[1][012]):[12][09][0-9][0-9])'

use Perl regex to validate the limits of date and month.

Pitfall: it might miss 31st of feb

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the comma to show the space allocation of files?

1083


How do I run a whois command?

1151


Which unix command lists files/folders in alphabetical order?

1739


What is the difference between cat and more command?

1289


What is awk good for?

1134


How can we use grep command in unix?

1199


What is the use of find command in unix?

1141


What is {} in find command?

1100


Which command will print your home directory on screen?

1078


What does the md command do?

1127


What do chmod command do?

1210


why metadb requires a seperate slice to create Solaris volume manager

3152


What are the unix commands?

1089


How do I run a bash script?

1177


How does shebang work?

1063