bash script help - finding last n log files in all sub folders
Hello everyone,
I am quite a bit puzzled by the following scripting need:
I have a tree of subfolders, starting from a root named "logs". There can be any number of knots, I will call them a, b and c in this attempt to explain things. Each knot can have n leaves, let's name them a1, a2, a3 and b1, and b2.
Each leaf folder will store log files, whose names are like YYYY-MM-DD.HHMMSS.log
The script I need will have to return the last n log files for every leaf, where n is as script parameter passed at runtime.
So it would look like this:
jeepescu@gondolin:/$ . myScript.sh 2
/home/jeepescu/logs/a/a1 2007-11-01.103005.log
/home/jeepescu/logs/a/a1 2007-11-01.102900.log
/home/jeepescu/logs/a/a2 2007-10-15.102105.log
/home/jeepescu/logs/a/a2 2007-09-11.103005.log
/home/jeepescu/logs/a/b1 2007-09-05.234900.log
/home/jeepescu/logs/a/b1 2007-09-11.102900.log
/home/jeepescu/logs/a/b2 2007-10-21.102105.log
/home/jeepescu/logs/a/b2 2007-09-17.103005.log
Now, is bash scripting a good tool for writing such a thing, or should I start looking into perl, python or other creature ?
Thanks in advance.
|