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
Give the command for finding the current date.
What is ‘ps’ command for?
How does pipe () work?
Name the unix command to find how many days the server has been up.
What is the first character of the output in ls l command?
What is a bash command?
What is time_t?
what is the advaantage of each user having its own copy of the shell?
Is there any method to erase all files in the current directory, along with its all sub-directories, by using only one command?
What do chmod command do?
What is grep in bash?
What happens when we execute a unix command?
What does grep v do?
What is “chmod” command?
What does the command '$ls | wc –l > file1' do?