1.Linux下查找文件
- 查找a.html和b.html
find . -name "a.html" -name "b.html"
2.Linux下查找并执行
- 命令1为:
find test/ -name "*.jpg" | xargs -i cp {} train
- 命令2为:
find test/ -name "*.jpg" -exec cp {} train \;
find test/ -name "*.jpg"是指在test文件夹下查找名为*.jpg的文件。
xargs命令是给其他命令传递参数的一个过滤器,也是组合多个命令的一个工具。-i会将xargs的内容赋值给**{}**。
-exec参数后面是指执行其后面的命令,-exec以;为结尾,由于各个系统中分号的意义不同,因此用\进行转义,即;,{}会被find命令的结果替换。
3.Linux下查找并排除
- 排除目录下所有以html结尾的文件:
find . -type f ! -name "*.html"
- 排除多种文件类型的示例:
find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.o" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"
4.nvidia-smi实时刷新并高亮显示状态
watch -n 1 -d nvidia-smi