grep
当通过命令应用到选定的文件时,我们希望显示每个文件的修改日期和时间find
。最终结果应如下所示:
2016-10-17 Mon 20:38:57 ./rest/47results.php: 5 :σχόλια, ιδέες facebook
从 47test.php 文件运行以下命令:
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\n" \
-exec grep -HTni "σχόλια" {} + ');
我们为每个修改的文件和每一行打印不同的行:
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 :Τα σχόλια σας
每个结果find
一个,每个grep
结果一个。
如开头所述,如何一个打印排序、组合结果为每个仅一行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 :Τα σχόλια σας