nano
テキスト処理
書き方
nano [file]画面の下に操作が書かれている素朴な編集器です。^O と ^X のキャレットは文字ではなく Ctrl を意味します。
よく使うオプション
| オプション | 意味 |
|---|---|
| Ctrl-O | Write the file out; the caret in ^O means Ctrl |
| Ctrl-X | Leave nano, offering to save first |
| Ctrl-W | Search; Alt-W repeats the search |
| -w | Do not wrap long lines, which config files need |
| -B | Keep a backup of the file as it was |
| +N | Open with the cursor on line N |
| --linenumbers | Show line numbers (nano 4.0 and later) |
例
sudo nano /etc/hostsCtrl-O to write, Ctrl-X to leave.
nano -w /etc/nginx/nginx.confNo line wrapping, so directives stay on one line.
nano +25 deploy.shOpens at line 25.
パイプでつないで使うのが本来の形です。ひとつで全部やるより、三つつないだ方が短くなります。
読み方
- 角括弧 [ ] は省いてよい部分です。
- 三点 … は複数並べられるという意味です。
- オプションは大文字小文字を区別します — -r と -R が別物のコマンドもあります。
よくある質問
Q. nano は何をしますか。
画面の下に操作が書かれている素朴な編集器です。^O と ^X のキャレットは文字ではなく Ctrl を意味します。
Q. どう打ちますか。
nano [file] — 角括弧は省いてよい部分です。
Q. よく使うオプションはいくつですか。
ここにまとめたのは7個です。全部は man nano にあります。このコマンドはテキスト処理の仲間です。
関連するコマンド
man ページ: man nano