0

I have got script like that:

#!/bin/sh
cd /home/gamesimport/
ls -t games*.xml | tail -n+2 | xargs rm
mv games*.xml games_ok.xml

It's just deleting old games*.xml files, renaming the lastest games.xml file but I would like also to change name if games.xml file is larger then 1 MB. How would I do that?

4

2 回答 2

2

简单地说,使用查找:

find some/where -name games\*.xml -size +1M -exec mv {} {}.big \;
于 2013-07-28T21:45:20.443 回答
2
FILESIZE=$(stat -c%s games_ok.xml) 
MAX=1048576
if [ $FILESIZE -ge $MAX ]; then
#do something else
fi

应该管用

于 2013-07-28T20:45:46.080 回答