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
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 01:37 PM
to find the file with full path surjyap Shell Programming and Scripting 5 01-18-2008 03:26 PM
How to delete Directory and inside files using Find command bmkreddy SUN Solaris 3 07-10-2007 03:35 PM
i want to delete a file based on existing file in a directory srivsn Shell Programming and Scripting 3 04-11-2006 05:38 AM
Script to cd into newest (dated) FTP directory steved Shell Programming and Scripting 3 01-17-2006 02:04 AM

Closed Thread
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
  #1 (permalink)  
Old 07-07-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Question find full directory and delete old dated file?

I want to write a code that will look for a particular directory which is full or more than 95% used, and will search older file and delete it. My code looks like this:


Code:
df -k|while read f1 f2 f3 f4 f5 f6
do

if expr '$f5' -ge '95%' || continue
 then
 echo $f5
 else
 echo "there is no critical situation!"
fi
done

find . -name "*" -size +100k |sort -nr |tail -1\
#find /cbmdata/00/gdd -name "LOGS*" |sort -nr |tail -1\
while read line
 do rm -f $line
done

of course upper part doesn t work to comparison because I need to format 95% to decimal 95, but I couldn't . Can you please advise me a convert method?
  #2 (permalink)  
Old 07-07-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,805

Code:
df -k | tr -d '%' | \
while read a b c d 
do
# do stuff 
done

will get remove the %
  #3 (permalink)  
Old 07-07-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
can I put an else if there is no problem in this case ??

I tried your code and worked, thanks.
last updated code :


Code:
ref=95
rep=0

df -k | tr -d '%' | \
while read a b c d e other
do

if (( $e >= $ref )) || continue
then
 rep=$e
 echo $rep

fi
done

can I take an else to indicate there is no full disk?
Thanks again
Closed Thread

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 07:42 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