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 / uttamjit

You can use the below command:
grep -o '[[0-9]*:[0-9]*:[0-9]*' infile

where infile is the input file to grep command.

Is This Answer Correct ?    16 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the command to compare two files in unix?

618


What is the unix command to confirm a remote host is alive or not?

578


What does grep v do?

557


Is there a way to erase all files in the current directory, including all its sub-directories, using only one command?

795


What is the pipe command?

574






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

676


What command is used to switching between users in unix?

558


How is the command '$cat file2 ' different from '$cat >file2 and >> redirection operators ?

757


What is awk command used for?

596


What is the nmap command?

579


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

558


What is the use of awk command in unix?

577


What is ctrl d?

592


How do you grep recursively?

553


What is the command to find hidden files in the current directory?

578