/usr/bin/ptx: 1 つまたは 2 つのユースケースを提供できますか?

/usr/bin/ptx: 1 つまたは 2 つのユースケースを提供できますか?

coreutilsに含まれているファイルのリストを見ている間、ptxを除いて提供されているすべてのコマンドを個人的にどのように使用するかの例を見つけることができました。 ptxを使う例を1つか2つ(または3つ)聞くことができますか?ユースケースはさまざまなほど良いです。

$ apropos ptx
ptx(1)         - produce a permuted index of file contents

ベストアンサー1

@Joseph R.承認された回答歴史を知るのも良いですが、どのように活用するのか見てみましょう。

ptxテキストから置換列インデックス(「ptx」)を生成します。たとえば、理解するのが最も簡単です。

$ 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

右側では、入力内の他の単語を見ることができます。左右の単語コンテキストそれらを囲んでいます。最初の単語は「1」です。最初の行の「b」と「c」の右側に表示されます。 2番目の単語は「b」で、2行目に表示されます。左側には「a」、右側には「c」があります。最後に、「c」が3行目に表示され、その後に「a」と「b」が表示されます。

これにより、テキスト内のすべての単語の行番号と周囲の単語を見つけることができます。本当にそうだと思いますがgrep、そうですか?違いはptx、テキストの構造、単語と文の論理単位を理解することです。これにより、ptx英語のテキストを処理するときのコンテキスト出力がgrepよりも関連性が高くなります。

James Ellroyの最初の段落を使用して比較しますptxgrep米国タブロイド:

$ 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.

ここにありますgrep(手動でカラーマッチングをサラウンドに変更//)。

$ 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.

これは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.

grep行の中心で短絡がすべて1行なので、grep出力はの出力と同じくらい簡潔で便利ではありませんptx

おすすめ記事