Shell little note
September 7, 2023
小笔记中~
cat
可以读取并显示文件内容
>
angle bracket sign: 可以把X写入A;可以overwirte
>>
append,而不是overwrite
<
从A中提取X
|
pipe character:
sudo
: “do as super user (root)”, 以root的身份执行以下命令
sudo su
: 更改为root身份 (exit
退出root shell)
/sys:并不是存在于电脑中实际的file,而是various kernal parameters
$
: not running as root.
#
: running as root
tee
: 把input写入文件并把input显示出来
grep
: 搜索
find
xdg-open
: 传递一个filename,他会以合适的program打开file
Shell 能实现的作用:
assign variables (记得$)
source
:用于在当前 Shell 会话中执行脚本文件的命令。它通常用于执行脚本文件,以便将脚本中定义的环境变量、函数或其他命令引入到当前 Shell 会话中,以供后续命令使用。
$?
:get you the error code from the previous command
- 0 : everything goes well
- 1 : 失败状态码
$_
:get you the last argument from previous command
!!
: replace the previous command if previous one is too long (比如 sudo 的时候用)
||
: OR, 如果第一个命令失败,那么执行第二个命令。
&&
: AND, execute the second part if the first part goes well
;
: 同一行分隔多个命令
<(
?
: 只会扩展一个字母 (project?)
diff
:
env
tldr
: Too Long; Don’t Read
find
: 查找 find /path/ -type f -name file-to-search
.
: current folder