awk abordagem:
awk 'NR==FNR{ split($5, data, "-"); a[data[3]"-"data[2]"-"data[1],$6]=$7; next}
/[0-9]{4}-[0-9]{2}-[0-9]{2}/{ d=$0 }{ if ($0~/^Account/) {
if ((d,$4) in a) { $0=$0"\tHints:" FS a[d,$4] }} print}'
FS=" |.txt:|/" output2.txt FS=" " output1.txt
A saída:
2017-04-02
Account: abcdef Domain: bytes.co CPU: 7.65 Mem: 0.09 MySQL: 0.7 Hints: 4216
%CPU 92.0 - /usr/bin/php /home/abcdef/public_html/index.php
%CPU 78.0 - /usr/bin/php /home/abcdef/public_html/wp-cron.php
%CPU 70.0 - /usr/bin/php /home/abcdef/public_html/index.php
--
Account: uvwxyz Domain: ppao.com CPU: 28.99 Mem: 0.61 MySQL: 1.5 Hints: 2122
%CPU 61.4 - /usr/bin/php /home/uvwxyz/public_html/index.php
%CPU 59.4 - /usr/bin/php /home/uvwxyz/public_html/index.php
%CPU 57.3 - /usr/bin/php /home/uvwxyz/public_html/index.php
Account: lmnopp Domain: nebu.org CPU: 27.57 Mem: 0.16 MySQL: 1.1 Hints: 1539
%CPU 79.0 - /usr/bin/php /home/lmnopp/public_html/index.php
%CPU 78.0 - /usr/bin/php /home/lmnopp/public_html/index.php
%CPU 73.0 - /usr/bin/php /home/lmnopp/public_html/index.php
2017-04-01
Account: abcdef Domain: bytes.co CPU: 6.68 Mem: 0.05 MySQL: 0.4 Hints: 3291
%CPU 93.0 - /usr/bin/php /home/abcdef/public_html/index.php
%CPU 79.0 - /usr/bin/php /home/abcdef/public_html/index.php
%CPU 69.0 - /usr/bin/php /home/abcdef/public_html/index.php
--
Account: uvwxyz Domain: ppao.com CPU: 29.80 Mem: 0.49 MySQL: 1.0 Hints: 1765
%CPU 87.0 - /usr/bin/php /home/uvwxyz/public_html/index.php
%CPU 86.5 - /usr/bin/php /home/uvwxyz/public_html/index.php
%CPU 85.8 - /usr/bin/php /home/uvwxyz/public_html/index.php
Account: lmnopp Domain: nebu.org CPU: 24.78 Mem: 0.14 MySQL: 1.0 Hints: 1607
%CPU 79.0 - /usr/bin/php /home/lmnopp/public_html/index.php
%CPU 72.0 - /usr/bin/php /home/lmnopp/public_html/index.php
%CPU 68.0 - /usr/bin/php /home/lmnopp/public_html/index.php
-
FS=" |.txt:|/" output2.txt
- separador de campo personalizado para o arquivooutput2.txt
-
split($5, data, "-")
- dividir cada valor de data (por exemplo,01-04-2017
) ao processaroutput2.txt
file -
data[3]"-"data[2]"-"data[1]
- reorganize as partes da data para fornecer correspondência entre dois arquivos -
a[data[3]"-"data[2]"-"data[1],$6]=$7
- acumulando dicas usando o índice de string complexo -
/[0-9]{4}-[0-9]{2}-[0-9]{2}/{ d=$0 }
- captura o valor da data ao processaroutput1.txt