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

What is ‘ps’ command for?

871


What is the search command in unix?

841


What is the use of the tee command?

840


How do I use nslookup?

783


Who command in unix?

808


Explain the terms ‘system calls’ and ‘library functions’ with respect to unix commands?

923


What's a command word?

819


What are the commands in UNIX to list the files in a Directory?

841


Why is shebang used?

822


What are bash commands?

819


How do I delete files from command prompt?

846


What is command substitution?

918


Who invented grep?

886


Explain command to view process running?

838


What is the command to view process running?

824