Die akzeptierte Antwort von @Joseph R. mit der Historie ist gut, aber schauen wir uns an, wie sie verwendet werden könnte.
ptxgeneriert aus text einen permutierten term index ("ptx"). Ein Beispiel ist am einfachsten zu verstehen:
$ cat input
a
b
c
$ ptx -A -w 25 input
:1: a b c
:2: a b c
:3: a b c
^^^^ ^ ^^^^-words to the input's right
| +-here is the actual input
+-words to the input's left
Unten rechts sehen Sie die verschiedenen Wörter aus der Eingabe und den sie umgebenden Kontext für das linke und rechte Wort . Das erste Wort ist "a". Es tritt in Zeile 1 auf und wird von "b" und "c" zu seiner Rechten gefolgt. Das zweite Wort ist "b", das in Zeile zwei mit "a" links und "c" rechts davon vorkommt. Schließlich kommt "c" in Zeile drei vor und wird von "a" und "b" fortgesetzt.
Auf diese Weise können Sie die Zeilennummer und die umgebenden Wörter zu jedem Wort in einem Text finden. Das klingt sehr nach grep, oder? Der Unterschied besteht darin, dass ptxdie Struktur von Text in logischen Einheiten von Wörtern und Sätzen verstanden wird. Dies macht die kontextbezogene Ausgabe von ptxbei englischen Texten relevanter als grep.
Vergleichen wir ptxund grepverwenden wir den ersten Absatz von James Ellroys amerikanischem Tabloid :
$ cat text
America was never innocent. We popped our cherry on the boat over and looked back with no regrets. You can’t ascribe our fall from grace to any single event or set of circumstances. You can’t lose what you lacked at conception.
Hier ist grep(mit Farbübereinstimmungen, die manuell geändert wurden, um von umgeben zu sein //):
$ grep -ni you text
1:America was never innocent. We popped our cherry on the boat over and looked back with no regrets. /You/ can’t ascribe our fall from grace to any single event or set of circumstances. /You/ can’t lose what /you/ lacked at conception.
Hier ist ptx:
$ ptx -Afo <(echo you) text
text:1: /back with no regrets. You can’t ascribe our fall/
text:1: /or set of circumstances. You can’t lose what you/
text:1: /. You can’t lose what you lacked at conception.
Da grepdieser Absatz zeilenorientiert ist und nur aus einer Zeile besteht, ist die grepAusgabe nicht ganz so präzise oder hilfreich wie die Ausgabe von ptx.