Нелегкая была задачка, вытащить статистику, да еще и среднюю за месяц. Учитывая то, что логи-то ежедневно бекапятся в ГЗ архив. И понял я что нужно мне:
Перебирать список гз файлов,
Искать строку внутри архивов не распаковывая их.
Первая задача проста надеюсь а вот вторая...:
Короче zgrep вам в руки и вперед! А если он вам не нравится по известным только вам причинам то можете взять и zcat .
Ну и примерчик (перчик):
zcat /yourfile.gz | grep string
zgrep 'value to find' filename.gz
Hi to all,
A little bit hard task to get the statistics for a month when your log files are backed up everyday for a separate GZ archive. I understood what i needed:
List gz files
Search a string inside archive without uncompressing
First task you can do by yourselves but the next one...:
Take zgrep and its all! And if you dont like it (i dont know why) you can use zcat .
And off course an example (xample :) )
zcat /yourfile.gz | grep string
zgrep 'value to find' filename.gz
For some version of Linux zgrep without -a parameter gives result such the following:
ОтветитьУдалитьBinary file (standard input) matches. To bypass this result we need use
zgrep -a 'value to find' filename.gz