The Missing Semester

Table of Contents

1 Resources

The Missing Semester: 2020 2019

2 Overview

# sudo 和管道 (pipe) 的结合
$ echo 3 | sudo tee brightness

3 Shell 脚本和工具

3.1 脚本

3.1.1 参数

  • $_ - 最近一次命令的最后一个参数 Esc-. 交互式 shell 中的对等功能
  • $$ - 当前脚本的 PID

3.1.2 命令返回码的快速检查

false || echo "Oops, fail"
# Oops, fail

true && echo "Things went well"
# Things went well

3.1.3 命令输出的处理

<(CMD) 用命令的输出作为 STDIN, 比如: diff <(ls foo) <(ls bar)

3.1.4 arguments by rules

  • {}
    • image.{png,jpg} => image.png image.jpg
    • touch {foo, bar}/{a..h} => 创建文件 foo/a, foo/b, … foo/h, bar/a, … bar/h

4 Editors

I use Emacs

5 Data Wrangling

6 Command-line Environment

6.1 Job Control

SIGTERM,用 kill -TERM <PID> 来发送

6.2 Remote Machines

6.2.1 SSH 端口转发

  • Local Port Forwarding
    • ssh -L 123:localhost:456 remotehost
    • ssh -L 123:farawayhost:456 remotehost
  • Remote Port Forwarding
    • ssh -R 123:localhost:456 remotehost
    • ssh -R 123:nearhost:456 remotehost

7 Version Control

8 Debugging and Profiling

logger "Hello Logs"
# On macOS
log show --last 1m | grep Hello
# On Linux
journalctl --since "1m ago" | grep Hello

9 Metaprogramming

10 Security and Cryptography

11 Potpourri

Author: sinxccc

Created: 2020-06-18 Thu 16:17