常见命令
创建文件夹然后进入
$ mkdir my-project && cd "$_"
查看文件夹的大小
$ du -sh project-name
对目标文件内容进行筛选
$ cat package.json | grep lodash -A 5
-A
和 -B
分别表示 after 和 before,显示筛选之后的行数数量的文件
从头/尾显示内容
$ head -n 10 package.json
$ tail -n 10 package.json
输出之后显示行号
$ cat -n package.json
运行文件中的命令
$ source ~/.zshrc
向文件中追加内容
$ mkdir temp.txt
$ echo 'hello' >> temp.txt
向文件中添加内容
$ mkdir temp.txt
$ echo 'hello' > temp.txt
查看进程
# 查看所有运行中的进程
$ ps aux
# 查看特定的进程
$ ps aux | grep string
显示运行进程的动态实时信息
$ top
查找文件
以某个类型来进行文件查找
$ find root_path -type d
这里的 type
可以有三个参数:
- -type d: 文件夹
- -type f: 文件
- -type l: symlinks
以文件名来进行查找
$ find root_path -name '*.py'
# 不考虑大小写
$ find root_path -type d -iname '*lib*'
以某个时间为节点进行查找
# 查找过去7天进行修改的文件
$ find root_path -mtime -7
以文件尺寸为筛选项
$ find root_path -size +500K -size -10M
去除某个文件夹
fint root_path -name '*.js' -not -path './node_modules/*'