您好我尝试在文件夹中创建bash功能搜索视频文件,如果查找文件大小超过32mb则显示msg文件大小超过32MB 帮我完成
我的代码
RESULTS_SIZE=$(find /folder/ -maxdepth 1 -iregex ".*\.\(mov\|mpeg\|wav\|mp4\|avi\|mpg\|flv\|WMV\|AVI\|mkv\)" -exec stat -c %s "{}" \;)
if [ "$RESULTS_SIZE" -gt 32768 ]
then
echo "Results file has exceeded 32MB in size." exit 1;
fi
答案 0 :(得分:2)
只需使用-size
的{{1}}开关,find
前缀大小低于N,-
大小超过N,+
后缀用于咬,千字节,兆字节或千兆字节:
b,k,M,G
如果你想在bash中使用它,你可以这样做:
find . -maxdepth 1 -iregex "the_regex" -size +32M -printf "Viseo over 32 MB (size %s): %h/%f"