0

I have multiple files which have raw CDRs in them. The files are named in the pattern cdr.log-2013-06-08-0100. There are multiple files like so:

cdr.log-2013-06-07-0000
cdr.log-2013-06-07-0100
.
.
cdr.log-2013-06-08-2200
cdr.log-2013-06-08-2300

I need to grep out a string from a range of files say between the date 6th june 2013 to 9th june 2013, how can I accomplish this?

Kyslik
  • 8,217
  • 5
  • 54
  • 87
  • 3
    try this http://www.unix.com/unix-dummies-questions-answers/143155-searching-date-range-filenames.html – Kyslik Jun 08 '13 at 09:26

1 Answers1

1

To grep a string from specific range of file.

find . -regex ".*cdr\.log-2013-06-0[6-9]-.*" -exec grep 'your string' {} +
jaypal singh
  • 74,723
  • 23
  • 102
  • 147
  • `zgrep "search text" /mnt/internal-app/logs/internal-app.log_2019-08-23*` works for me but `find . -regex "/mnt/internal-app/logs/internal-app.log_2019-08-23.*" -exec grep 'search text' {} +` does not work for me. – Sandeepan Nath Aug 29 '19 at 15:04