Lecture 01 Shell
使用Windows的同学请先安装WSL或Linux虚拟机
Argument Parsing
参数间以空格分隔,第一个参数是命令,例如
1 | ❯ echo hello world |
cd: 切换当前目录
1 | ❯ cd ~ |
一个命令就是一个program,当你输入一个命令时,shell会对$PATH变量中记录的路径逐个寻找,直到找到这个命令
1 | ❯ which date |
which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in a strictly POSIX-conformant shell.
It does this by searching the PATH for executable files matching the names of the arguments. It does not canonicalize path names.
grep 在文件中筛选
1 | ❯ cat test.txt |
awk
sed
管道符 | 把左侧命令的输出作为右侧命令的输入
- Title: Lecture 01 Shell
- Author: Hare Fuyukawa
- Created at : 2026-03-29 20:03:04
- Updated at : 2026-06-03 17:38:49
- Link: https://redefine.ohevan.com/Missing-Semester/MS/MS-1/
- License: This work is licensed under CC BY-NC-SA 4.0.
Comments