对于之前的MIT课的一些要点概括
Vim
Ctrl + d
向下滚动半屏Ctrl + u
向上滚动半屏w
(next word),b
(beginning of word),e
(end of word)gg
移动到文件头G(shift + g)
移动到文件尾0
移动到本行第一个字符上$
移动到行尾- 查找:
/{regex}
,n
/N
下一个匹配 u
撤销(Undo)Ctrl + r
重做(Redo)- 删除:
d{motion}
- e.g.
dw
is delete word,d$
is delete to end of line,d0
is delete to beginning of line - 修改:
c{motion}
- e.g.
cw
is change word
- e.g.
Connecting programs
读写文件:The simplest form of redirection is < file
and > file
. These let you rewire the input and output streams of a program to a file respectively:
1 | $ echo hello > hello.txt |
数据传输:Pretty much any time you use the |
operator, you are performing some kind of data wrangling. Consider a command like journalctl | grep -i intel
.
1 | $ ssh myserver 'journalctl | grep sshd | grep "Disconnected from"' > ssh.log |
Regular expressions
常见表达:
.
means “any single character” except newline*
zero or more of the preceding match+
one or more of the preceding match[abc]
any one character ofa
,b
, andc
(RX1|RX2)
either something that matchesRX1
orRX2
^
the start of the line$
the end of the line
sed usage:
1 | sed 's/{{regex}}/{{replace}}/' {{filename}} |
Replace all occurrences of an extended regular expression in a file, and print the result
Useful to INSTALL
1 | tldr #too long don't read |