[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Wed Mar 16 11:32:40 2005 -->
- <!--x-from-r13: cenf ng plpybrnfgrea.pbz (cenf ng plpybrnfgrea.pbz) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] file size in shell script? -->
- <li><em>date</em>: Wed Mar 16 11:32:40 2005</li>
- <li><em>from</em>: pras at cycloeastern.com (pras at cycloeastern.com)</li>
- <li><em>in-reply-to</em>: <<a href="msg00284.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00284.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] file size in shell script?</li>
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
> <a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
--
________________________________________________________________________
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
|
________________________________________________________________________
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00289" href="msg00289.html">[ale] file size in shell script?</a></strong>
<ul><li><em>From:</em> keith.watson at gtri.gatech.edu (Keith R. Watson)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00284" href="msg00284.html">[ale] file size in shell script?</a></strong>
<ul><li><em>From:</em> jloden at toughguy.net (Jay Loden)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00286.html">[ale] Fetchmail</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00288.html">[ale] Fetchmail</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00284.html">[ale] file size in shell script?</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00289.html">[ale] file size in shell script?</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00287"><strong>Date</strong></a></li>
<li><a href="threads.html#00287"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>