[ale] file size in shell script?

Keith R. Watson keith.watson at gtri.gatech.edu
Wed Mar 16 12:03:26 EST 2005


>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

Jay,

Try the stat command.

keith

-- 

Keith R. Watson                        GTRI/ISD
Systems Support Specialist III         Georgia Tech Research Institute
keith.watson at gtri.gatech.edu           Atlanta, GA  30332-0816
404-894-0836



More information about the Ale mailing list