find命令查找文件并清空

#!/bin/bash
for i in $(find /data -type f -name 0000*)
do
    cat /dev/null > $i
done
#上述脚本首先查找匹配0000的文件,然后将文件置空
括号中的命令data表示查找的文件目录

通过find 命令查找多个文件的命令如下:

find /data -type f -name file1 -or -name file2 -or -name file3 -or -name file4

上述命令中通过-or表示或,查找多个文件使用或命令

标签