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