[ale] file size in shell script?

pras at cycloeastern.com pras at cycloeastern.com
Wed Mar 16 11:32:40 EST 2005


I tried this with a 30 mb file on my machine.


x=`du -m /tmp/PPTFL10.exe | cut -f1 `
echo $x
30

you can try something like 

if [ $x -le 4000 ]
then
	echo its less then or equal to 4000
else
	echo its over 4000
fi


On Wed, Mar 16, 2005 at 04:10:28AM +0000, Jay Loden wrote:
> 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
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale

-- 
________________________________________________________________________
Prasanna Subash            | If I'd known computer science was going to 
pras at cycloeastern.com      | be like this, I'd never have given up being
                           | a rock 'n' roll star.   -- G. Hirst 
                           | 
________________________________________________________________________



More information about the Ale mailing list