We want to show each file's modified date and time when applying grep
to selected files by the find
command. The final result should look like:
2016-10-17 Mon 20:38:57 ./rest/47results.php: 5 :σχ?λια, ιδ?ε? facebook
Running the following from 47test.php file:
system('export TZ=":Europe/Athens"; find . -name "*.*"
-not ( -path ./admin -prune )
-not ( -path ./people/languages -prune )
-not ( -path ./include -prune )
-type f -mmin -10
-printf "%TY-%Tm-%Td %Ta %TH:%TM:%TS %p
"
-exec grep -HTni "σχ?λια" {} + ');
we get distinct lines printed for each modified file and each line:
2016-10-17 Mon 21:09:55.0000000000 ./47test.php
2016-10-17 Mon 20:40:30.0000000000 ./places/00testout.txt
2016-10-17 Mon 20:38:57.0000000000 ./rest/47results.php
./47test.php: 22 :-exec grep -HTni "σχ?λια" {} + ');
./rest/47results.php: 5 :σχ?λια, ιδ?ε? facebook
./rest/47results.php: 6 :σχ?λια, ιδ?ε? twitter
./rest/47results.php: 7 :Τα σχ?λια σα?
One for each find
and one for each grep
result.
As mentioned in the beginning, how can one print sorted, combined results in just one line for each grep
?
2016-10-17 Mon 21:09:55 ./47test.php 22 :-exec grep -HTni "σχ?λια" {} + ');
2016-10-17 Mon 20:38:57 ./rest/47results.php: 5 :σχ?λια, ιδ?ε? facebook
2016-10-17 Mon 20:38:57 ./rest/47results.php: 6 :σχ?λια, ιδ?ε? twitter
2016-10-17 Mon 20:38:57 ./rest/47results.php: 7 :Τα σχ?λια σα?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…