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

Give the command for finding the current date.

1173


What is ‘ps’ command for?

1239


How does pipe () work?

1146


Name the unix command to find how many days the server has been up.

1208


What is the first character of the output in ls l command?

1262


What is a bash command?

1238


What is time_t?

1163


what is the advaantage of each user having its own copy of the shell?

2614


Is there any method to erase all files in the current directory, along with its all sub-directories, by using only one command?

1285


What do chmod command do?

1286


What is grep in bash?

1116


What happens when we execute a unix command?

1195


What does grep v do?

1099


What is “chmod” command?

1241


What does the command '$ls | wc –l > file1' do?

1299