回答:
「すべての空白スペースを削除する」とは、次のいずれかを意味します。
0x20。\t」を含むすべての水平スペースを削除します\n」などを含むすべての空白を削除しますsedそれが何らかの隠れた理由の要件ではない場合は、ジョブに適したツールを使用することをお勧めします。
このコマンドtrの主な用途は、文字のリストを他の文字のリストに変換することです(そのため「tr」という名前になります)。まれに、空の文字リストに変換できます。オプション-d(--delete)は、リストに表示される文字を削除します。
文字のリストは、[:...:]構文で文字クラスを使用できます。
tr -d ' ' < input.txt > no-spaces.txttr -d '[:blank:]' < input.txt > no-spaces.txttr -d '[:space:]' < input.txt > no-spaces.txtsedsedでは、[:...:]文字クラスの構文をregexpsの文字セットの構文と組み合わせる必要があり[...]、やや混乱します[[:...:]]。
sed 's/ //g' input.txt > no-spaces.txtsed 's/[[:blank:]]//g' input.txt > no-spaces.txtsed 's/[[:space:]]//g' input.txt > no-spaces.txttr -d ' ' < input.txt > no-spaces.txt。
trます。(他のどこかで見ますか?)