The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sh -help with case statement (should be simple) kuliksco Shell Programming and Scripting 1 11-19-2007 10:04 PM
Help with if statement in ksh script stepnkev Shell Programming and Scripting 2 05-07-2007 02:25 PM
Script does not execute Insert Statement Amruta Pitkar Shell Programming and Scripting 4 08-25-2006 12:14 AM
What's wrong with this simple statement? mharley Shell Programming and Scripting 7 03-04-2005 07:30 AM
Shell script automation using case statement ianf Shell Programming and Scripting 6 09-12-2002 10:17 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-12-2008
bpage bpage is offline
Registered User
  
 

Join Date: May 2008
Posts: 1
Using simple if statement in script

Hello,

I am trying to create a simple script that will check the disk usage of a drive, and if it is over the limit it will delete the oldest ten files. everything is working except for when i implement the if statement i get the error
/usb0: zero divisor.

I am pretty sure that the du -k /usb0 command is putting whitespace before the actual available space and that is causing the problem. Is there a way to get around that? thanks


Code:
diskusage=`du -k /usb0`
echo "Current disk usage: $diskusage"
x=0
if [ "$diskusage" -gt 200000 ] ; then
while [[ $x -lt 2 ]] ; do
deletefile=`ls /usb0 | head -1`
echo "Deleting File Now..."	
rm /usb0/"$deletefile" 
echo "File $deletefile was removed." 
x=`expr $x + 1`

done
fi


Last edited by bpage; 05-12-2008 at 02:38 PM..
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0