nano

テキスト処理

書き方

nano [file]

画面の下に操作が書かれている素朴な編集器です。^O と ^X のキャレットは文字ではなく Ctrl を意味します。

よく使うオプション

オプション意味
Ctrl-OWrite the file out; the caret in ^O means Ctrl
Ctrl-XLeave nano, offering to save first
Ctrl-WSearch; Alt-W repeats the search
-wDo not wrap long lines, which config files need
-BKeep a backup of the file as it was
+NOpen with the cursor on line N
--linenumbersShow line numbers (nano 4.0 and later)

sudo nano /etc/hosts

Ctrl-O to write, Ctrl-X to leave.

nano -w /etc/nginx/nginx.conf

No line wrapping, so directives stay on one line.

nano +25 deploy.sh

Opens at line 25.

パイプでつないで使うのが本来の形です。ひとつで全部やるより、三つつないだ方が短くなります。

読み方

  • 角括弧 [ ] は省いてよい部分です。
  • 三点 … は複数並べられるという意味です。
  • オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。

よくある質問

Q. nano は何をしますか。

画面の下に操作が書かれている素朴な編集器です。^O と ^X のキャレットは文字ではなく Ctrl を意味します。

Q. どう打ちますか。

nano [file] — 角括弧は省いてよい部分です。

Q. よく使うオプションはいくつですか。

ここにまとめたのは7個です。全部は man nano にあります。このコマンドはテキスト処理の仲間です。

関連するコマンド

man ページ: man nano