我已将以下内容与其他一些文章放在一起,但它似乎不起作用。我最终要做的是检查目录大小,然后如果目录有新的内容超过一定的总大小,它会让我知道。Bash脚本编制希望查找目录的大小,如果大小大于x,则执行任务
#!/bin/bash
file=private/videos/tv
minimumsize=2
actualsize=$(du -m "$file" | cut -f 1)
if [ $actualsize -ge $minimumsize ]; then
echo "nothing here to see"
else
echo "time to sync"
fi
this is the output:
./sync.sh: line 5: [: too many arguments
time to sync
我是新来的bash脚本,所以提前谢谢你。
向du命令添加选项'-s'。 – Cyrus
通过打印来查看实际大小的价值。 'echo“$ actualsize”' –
或者'echo $(du -m“$ file”)' –