1 环境变量
创建变量:declare tmp
变量赋值:tmp=shiyanlou
读取变量:echo $tmp
2 命令的查找路径与顺序
查看变量内容:echo $path
创建shell脚本:gedit hello_shell.sh
添加内容:for ((i=0;i<10;i++));do
echo "hello shell"
done
exit o
为文件添加可执行权限:chmod 755 hello_shell.sh
执行脚本:./hello_shell.sh
创建目录:mkdir mybin
移动文件:mv hello_shell.sh mybin/
运行程序:cd mybin
./hello_shell.sh
3 修改与删除变量
修改变量:$ path=${path%/home/shiyanlou/mybin}
$ path=${path%*/mybin}
删除变量:unset tmp
4 让环境变量立即生效:source ./zshrc or ../.zshrc
5 搜索文件;whereis who
locate /etc/sh
which man
sudo find /etc/ -name interfaces
与时间相关的命令参数:
参数 | 说明 |
---|---|
-atime | 最后访问时间 |
-ctime | 最后修改文件内容的时间 |
-mtime | 最后修改文件属性的时间 |
下面以 -mtime
参数举例:
-mtime n
:n 为数字,表示为在 n 天之前的“一天之内”修改过的文件-mtime +n
:列出在 n 天之前(不包含 n 天本身)被修改过的文件-mtime -n
:列出在 n 天之内(包含 n 天本身)被修改过的文件newer file
:file 为一个已存在的文件,列出比 file 还要新的文件名
sudo apt-get install cmatrix