どーも!marusukeです!
テキストファイルの行の桁数を調整するコマンドfmtについて説明します!
fmtコマンドでできること
fmt コマンドは、テキストファイルの行の桁数を調整することができるコマンドです
このコマンドは、長い行を短く分割したり、短い行を結合して指定した幅に合わせたりすることができます。テキストファイルを読みやすく整形することが可能になります
fmtコマンドの使用例
以下の内容のfile.txtを1行50文字に調整します
bash-3.2$ cat file.txt
The `fmt` command in Linux is a convenient tool for formatting text to a specified width. This command formats text for readability by specifying paragraph and line lengths. It proves useful, for instance, when formatting emails or documents.
bash-3.2$ fmt -w 50 file.txt
The `fmt` command in Linux is a convenient tool
for formatting text to a specified width. This
command formats text for readability by specifying
paragraph and line lengths. It proves useful, for
instance, when formatting emails or documents.
fmtコマンドのオプション
| オプション | 説明 |
|---|---|
-w, --width=数値 | 行の幅を指定します。この幅にテキストを調整します。 |
-g, --goal=数値 | 最適な行の幅を指定します。-wオプションと併用すると、指定した幅内で可能な限り-gに近づけます。 |
-u, --uniform-spacing | 単語間のスペースを一つに統一します。 |
-s, --split-only | 行を結合せずに、長い行を指定の幅で分割するだけにします。 |
以上です!
ここまで読んでいただきありがとうございました!




コメント