0%

【Missing Semester@MIT】总结

对于之前的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

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
2
3
4
5
6
$ echo hello > hello.txt
$ cat hello.txt
hello
$ cat < hello.txt > hello2.txt
$ cat hello2.txt
hello

数据传输: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
2
$ ssh myserver 'journalctl | grep sshd | grep "Disconnected from"' > ssh.log
$ less 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 of a, b, and c
  • (RX1|RX2) either something that matches RX1 or RX2
  • ^ 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
2
3
4
5
tldr #too long don't read
rg #ripgrep
nnn #file system
tmux
fuck