3

tr(Unixコマンド)の-cオプションを理解するのに問題があります。

このフォーマットを見てtrください:tr [Options] set1 [set2]

これは、「set1の補数(つまり、set1にないすべての文字)を使用する」という意味-cの[オプション]であると理解しています。ただし、このコマンドの使用方法の例を挙げて、利点を説明してください。tr

ありがとうございました

4

1 に答える 1

3

It means to complement the character range. When you complement the string A-Z you get Any character that is not in A ... Z.

Sometimes it is much easier to specify a task with the complement. Suppose you want to count the number of semicolons in a C source file. You delete all non-semicolons and count what's left:

tr -d -c \; < file.c | wc -c
于 2012-09-09T16:33:12.297 に答える