Lecture videos from the class offered during MIT’s Independent Activities Period in 2020.
https://missing.csail.mit.edu/
一些重要的点:
The Shell:
- <
curl --head --silent google.com | grep --ignore-case content-length | cut --delimiter=' ' -f2
- tee
Shell Tools and Scripting
- $的各种用法:
$0
– Name of the script$1
to$9
– Arguments to the script.$1
is the first argument and so on.$@
– All the arguments$#
– Number of arguments$?
– Return code of the previous command$$
– Process Identification number for the current script!!
– Entire last command, including arguments. A common pattern is to execute a command only for it to fail due to missing permissions, then you can quickly execute it with sudo by doingsudo !!
$_
– Last argument from the last command. If you are in an interactive shell, you can also quickly get this value by typingEsc
followed by.
- for file in $(ls)
- diff <(ls foo) <(ls bar)
- test [ ] [[ ]] What is the difference between test, [ and [[ ? ( 结论是用 [[ ]] )
- {} 扩展
convert image.{png,jpg}
# Will expand to
convert image.png image.jpg
- 可以使用shellcheck
- shebang
- TLDR pages
- find
- rg
- fd
- fish shell
- zsh
- fasd 排序文件
- xargs
Editors(vim)
Data Wrangling
- 正则表达式
- convert
- sed
- awk
- sort
ssh myserver journalctl
| grep sshd
| grep "Disconnected from"
| sed -E 's/.*Disconnected from (invalid |authenticating )?user (.*) [^ ]+ port [0-9]+( \[preauth\])?$/\2/'
| sort | uniq -c
| sort -nk1,1 | tail -n10
| awk '{print $2}' | paste -sd,