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 use of the tee command?

593


What are filter commands in unix?

548


Describe the usage and functionality of the command rm –r * in unix?

820


What is rmdir command?

546


What is a command and examples?

577






Which command will print your home directory on screen?

540


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

2030


How does shebang work?

584


When i run a programm of orphan process. Instead of getting child's parent (ppid)=1 ..i get 1400 and it varies as per system. How can i findthe right soluion??? My pgm: #include # include int main() { int pid; pid=fork(); if(pid < 0) {exit(-1);} else if(pid==0) { printf("Child Process is Sleeping ..."); sleep(10); printf("Orphan Child's Parent ID : %u ",getppid()); } else { printf("Parent Process Completed ... %u ",getpid()); exit(0); } return 0; } Output:

1757


What does the command ' $who | sort –logfile > newfile' do?

761


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

558


What does #!/ Bin sh do?

584


What is difference between grep and find command in unix?

576


How do I use grep to find a file?

577


What is grep r?

585