Hi All,
I'd be grateful for some guidance as my Bash skills aren't cutting the mustard!
I have a need to process a large number (thousands) of small text files, to find the total numbers of files that contain certain combinations of text strings. The files are spread through multiple subdirectories.
The 'variables' in each file are a device number such as [001, 002, 003... 006], a date (mm/yy) string in the format "/10/14" (October 14) and a text string, which will either be present or not. If present it will read 'Settled'.
My need is to produce a simple report that says, for example:
001, /09/14 - Settled: 325
001, /09/14 - Total files: 817
001, /10/14 - Settled: 842
001, /10/14 - Total files: 2812
002, /09/14 - Settled: 665
002, /09/14 - Total files: 1823
etc etc.
(Format isn't important - I just need a count for each category).
I'm guessing I need to do something like:
Code:
For each [001... 006]
For each [valid month text string]
find files containing (<device> AND <date>)
Count total matching files - write number to file
find files containing (<device> AND <date> AND "Settled")
Count total matching files - write number to file
I tried using piped grep commands, moving matching files to a directory, grepping them again and then filtering the output list through wc -l, but this got messy fast!
I'm looking for a way to input the device numbers (001, 002 etc) and the valid month dates (from a file maybe?) and loop through them counting the matches.
I'm starting to think that Bash isn't the right tool, and something like Perl might be better, but I'm clueless with Perl! Anyone have suggestions please?
Thanks all.
Frustrated from Wales.