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
What is awk good for?
How can we use grep command in unix?
What are grep patterns?
Write a command that will display files in the current directory, in a colored, long format.
Write a command to display a file’s contents in various formats?
Why is shebang used?
What is {} in find command?
What does the md command do?
What is the use of find command in unix?
What is difference between grep and find command in unix?
Which command will print your home directory on screen?
What is the significance of the 'tee' command?
What is awk command used for?
Write a command that will find all text files in a directory such that it does not contain the word "amazing" in any form (that is, it must include the words amazing, amazing, or amazing)?
How do I open a port?