Risposte:
È possibile ottenere questo risultato con sorte uniq.
esempio:
[john @ awesome ~] $ echo -e "test \ ntest \ ntest \ nanother test \ ntest" test test test un altro test test [john @ awesome ~] $ echo -e "test \ ntest \ ntest \ nanother test \ ntest" | ordina | uniq un altro test test
a seconda dei dati potresti voler utilizzare anche alcuni degli switch.
sort -uinvece di sort | uniq. Salva un processo, riduce l'I / O totale e riduce il numero totale di confronti che devono essere effettuati.
Puoi usare:
grep -rohP "(mySearchString)" . | sort -u
-r: ricorsivo
-o: stampa solo la parte corrispondente del testo
-h: non stampare i nomi dei file
-P: regex in stile Perl (puoi usare -E invece a seconda del tuo caso)
sort -uè meglio di sort | uniq, come ha sottolineato @Chris Johnsen.
sortprimauniqnel caso in cui i dati non vengano ordinati. Altrimentiuniqnon funzionerà completamente.