我想获取包含所有模式同时!
的文件the-user@MAC-001 logs-delete % grep -RHl ",\"estadoOperacion\":\"PP\"" ~/Company/logs-delete/pf*
/Users/the-user/logs-delete/pf_3.0_20241024_131845.log
/Users/the-user/logs-delete/pf_3.0_20241025_075400.log
/Users/the-user/logs-delete/pf_3.0_20241028_141054.log
/Users/the-user/logs-delete/pf_3.0_20241029_083212.log
/Users/the-user/logs-delete/pf_3.0_20241029_124232.log
/Users/the-user/logs-delete/pf_3.0_20241104_103451.log
/Users/the-user/logs-delete/pf_3.0_20241106_073739.log
/Users/the-user/logs-delete/pf_3.0_20241106_124513.log
/Users/the-user/logs-delete/pf_3.0_20241107_094139.log
/Users/the-user/logs-delete/pf_3.0_20241108_065032.log
/Users/the-user/logs-delete/pf_3.0_20241108_094537.log
/Users/the-user/logs-delete/pf_3.0_20241108_154655.log
the-user@MAC-001 logs-delete % grep -RHl ",\"estadoOperacion\":\"OX\"" ~/Company/logs-delete/pf*
/Users/the-user/logs-delete/pf_3.0_20241028_102403.log
/Users/the-user/logs-delete/pf_3.0_20241028_141054.log
/Users/the-user/logs-delete/pf_3.0_20241028_143253.log
/Users/the-user/logs-delete/pf_3.0_20241029_065826.log
/Users/the-user/logs-delete/pf_3.0_20241029_083212.log
/Users/the-user/logs-delete/pf_3.0_20241029_124232.log
/Users/the-user/logs-delete/pf_3.0_20241029_160927.log
/Users/the-user/logs-delete/pf_3.0_20241030_065136.log
/Users/the-user/logs-delete/pf_3.0_20241030_072228.log
the-user@MAC-001 logs-delete % grep -RHl ",\"estadoOperacion\":\"SPAD\"" ~/Company/logs-delete/pf*
/Users/the-user/logs-delete/pf_3.0_20241029_083212.log
/Users/the-user/logs-delete/pf_3.0_20241029_124232.log
/Users/the-user/logs-delete/pf_3.0_20241106_124513.log
/Users/the-user/logs-delete/pf_3.0_20241108_065032.log
/Users/the-user/logs-delete/pf_3.0_20241108_094537.log
/Users/the-user/logs-delete/pf_3.0_20241108_154655.log
the-user@MAC-001 logs-delete %
我正在尝试:
the-user@MAC-001 logs-delete %
grep -RHl -e ",\"estadoOperacion\":\"SR\"" -e ",\"estadoOperacion\":\"OAD\"" -e ",\"estadoOperacion\":\"PP\"" -e ",\"estadoOperacion\":\"SPAD\"" -e ",\"estadoOperacion\":\"OX\"" ~/Company/logs-delete/pf*
/Users/the-user/logs-delete/pf_3.0_20241001_072248.log
/Users/the-user/logs-delete/pf_3.0_20241002_153232.log
/Users/the-user/logs-delete/pf_3.0_20241003_075357.log
/Users/the-user/logs-delete/pf_3.0_20241003_113433.log
/Users/the-user/logs-delete/pf_3.0_20241003_152330.log
/Users/the-user/logs-delete/pf_3.0_20241004_075536.log
/Users/the-user/logs-delete/pf_3.0_20241007_142857.log
/Users/the-user/logs-delete/pf_3.0_20241007_144142.log
/Users/the-user/logs-delete/pf_3.0_20241008_114436.log
/Users/the-user/logs-delete/pf_3.0_20241008_144330.log
/Users/the-user/logs-delete/pf_3.0_20241008_172634.log
/Users/the-user/logs-delete/pf_3.0_20241009_095809.log
/Users/the-user/logs-delete/pf_3.0_20241009_213218.log
/Users/the-user/logs-delete/pf_3.0_20241010_074449.log
/Users/the-user/logs-delete/pf_3.0_20241010_144036.log
/Users/the-user/logs-delete/pf_3.0_20241011_113226.log
/Users/the-user/logs-delete/pf_3.0_20241011_160243.log
/Users/the-user/logs-delete/pf_3.0_20241014_095831.log
/Users/the-user/logs-delete/pf_3.0_20241015_111718.log
/Users/the-user/logs-delete/pf_3.0_20241016_070147.log
/Users/the-user/logs-delete/pf_3.0_20241016_094720.log
/Users/the-user/logs-delete/pf_3.0_20241016_115045.log
/Users/the-user/logs-delete/pf_3.0_20241016_145233.log
/Users/the-user/logs-delete/pf_3.0_20241016_151614.log
/Users/the-user/logs-delete/pf_3.0_20241016_215805.log
/Users/the-user/logs-delete/pf_3.0_20241017_072014.log
/Users/the-user/logs-delete/pf_3.0_20241017_120459.log
/Users/the-user/logs-delete/pf_3.0_20241017_182521.log
/Users/the-user/logs-delete/pf_3.0_20241018_105402.log
/Users/the-user/logs-delete/pf_3.0_20241021_075142.log
/Users/the-user/logs-delete/pf_3.0_20241021_103556.log
/Users/the-user/logs-delete/pf_3.0_20241021_145449.log
/Users/the-user/logs-delete/pf_3.0_20241022_090917.log
/Users/the-user/logs-delete/pf_3.0_20241022_104625.log
/Users/the-user/logs-delete/pf_3.0_20241022_133342.log
/Users/the-user/logs-delete/pf_3.0_20241023_101721.log
/Users/the-user/logs-delete/pf_3.0_20241024_081816.log
/Users/the-user/logs-delete/pf_3.0_20241024_100650.log
/Users/the-user/logs-delete/pf_3.0_20241024_131845.log
/Users/the-user/logs-delete/pf_3.0_20241025_070917.log
/Users/the-user/logs-delete/pf_3.0_20241025_075400.log
/Users/the-user/logs-delete/pf_3.0_20241028_102403.log
/Users/the-user/logs-delete/pf_3.0_20241028_141054.log
/Users/the-user/logs-delete/pf_3.0_20241028_143253.log
/Users/the-user/logs-delete/pf_3.0_20241029_065826.log
/Users/the-user/logs-delete/pf_3.0_20241029_083212.log
/Users/the-user/logs-delete/pf_3.0_20241029_124232.log
/Users/the-user/logs-delete/pf_3.0_20241029_160927.log
/Users/the-user/logs-delete/pf_3.0_20241030_065136.log
/Users/the-user/logs-delete/pf_3.0_20241030_072228.log
/Users/the-user/logs-delete/pf_3.0_20241104_065520.log
/Users/the-user/logs-delete/pf_3.0_20241104_103451.log
/Users/the-user/logs-delete/pf_3.0_20241106_065517.log
/Users/the-user/logs-delete/pf_3.0_20241106_073739.log
/Users/the-user/logs-delete/pf_3.0_20241106_124513.log
/Users/the-user/logs-delete/pf_3.0_20241106_161638.log
/Users/the-user/logs-delete/pf_3.0_20241107_070046.log
/Users/the-user/logs-delete/pf_3.0_20241107_094139.log
/Users/the-user/logs-delete/pf_3.0_20241108_065032.log
/Users/the-user/logs-delete/pf_3.0_20241108_094537.log
/Users/the-user/logs-delete/pf_3.0_20241108_154655.log
/Users/the-user/logs-delete/pf_3.0_20241121_113359.log
如您所见,该行为类似于 OR,而不是 AND。
如何在 macOS 中修复我的句子以同时获取包含所有单词/模式的所有文件?
与
bash
:
(
grep -RHl ",\"estadoOperacion\":\"PP\"" ~/Company/logs-delete/pf*
grep -RHl ",\"estadoOperacion\":\"OX\"" ~/Company/logs-delete/pf*
grep -RHl ",\"estadoOperacion\":\"SPAD\"" ~/Company/logs-delete/pf*
) | sort | uniq -c | awk '$1==3' | sed 's/^ \+3\+ //'
输出:
/用户/用户/日志删除/pf_3.0_20241029_083212.log /Users/the-user/logs-delete/pf_3.0_20241029_124232.log