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

#1: grep '[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'
<filename> | more

from #1 output see which column is returned for date.

use next this command.

#1: grep '[0-9][0-9]-[0-9][0-9]-[0-9][0-9][0-9][0-9]'
<filename> | cut -f<from the first command> -d"<Delimeter
of file>

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I find previous commands in unix?

879


What are the differences among a system call, a library function, and a unix command?

859


What is grep in bash?

824


What is the use of tee command?

834


Write a command that will allow a unix system to shut down in 15 minutes, after which it will perform a reboot.

906


Why is it called a shebang?

843


What is the significance of the 'tee' command?

878


Which command is used to kill the last background job?

1072


Write a command that will display files in the current directory, in a colored, long format.

978


Is command prompt unix?

839


What does 'mkdir' command do in UNIX?

983


What is ctrl d?

850


What is .sh file?

876


How do I use grep to find a file?

857


Give the command for finding the current date.

813