[ale] file size in shell script?

Jay Loden jloden at toughguy.net
Wed Mar 16 11:14:57 EST 2005


I am making a backup script (BASH) for work to burn our backups to DVD...I 
thought I was all done with it until I tested it and found out that the
"split" command, which I was going to use to make sure the tar file(s) are 
4000m chunks, only works if the file is big enough to create at least one
4000m chunk.

Basically, I need either a way to test if the file is 4000m and if it is, then 
use split on it, or if it's not, then just burn it. (alternative
suggestions for splitting it up are also welcome, of course)

I tried making an if statement but couldn't for the life of me figure out how 
to get a file size in Bash and compare it to a number like 4000m. (i.e. if I 
use 'du filename' how do I return that into a variable and compare it?) 
Before I go and rewrite this whole backup script in something else (Perl, 
etc) I thought I'd ask if anyone could help me do it in Bash.

Thanks,
-Jay



More information about the Ale mailing list