![]() |
|
|||||||
| Programming C, bash, Python, Perl, PHP, Java, you name it. |
![]() |
|
|
Thread Tools | Display Modes |
|
|||
|
ok, I have never written a shell script before. What I need to do is remove the oldest files from a known directory when the hard disk is above a certain size, so that the hard disk never becomes full and the oldest data removed.
Any help would be grateful and even better if someone can code me the script
|
|
||||
|
__________________
OpenBSD LiveCDs/LiveDVDs |
|
|||
|
thanks for the link, but this seems to only remove files over n days. What I need to do is when the hard disk is greater the n percent full, remove the oldest files from the directory until the disk is lower than n percent full. Basically a FIFO.
|
|
|||
|
Quote:
Last edited by ocicat; 14th July 2008 at 05:44 PM. |
|
||||
|
because AWK is it's own language as well as a program (awk), I'll add to ocicats post by noting the easiest way to get a specific column out of 'df' output with awk.
Code:
df | awk '{ print $1 }'
Accessing the column(s) a line at a time is also easy as pie but I'll let you figure that out along with more useful things ;-)
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| matts: a sh script to mail files as attachments from the command line | J65nko | Guides | 6 | 12th October 2009 06:24 PM |
| Cleaning Portsnap files in /var/db/portsnap/files | bram85 | FreeBSD Ports and Packages | 2 | 5th October 2009 09:54 AM |
| finding files by uid | carpman | FreeBSD General | 3 | 5th February 2009 06:51 PM |
| Tried to create new partition using sysinstall but change is not permanent | disappearedng | FreeBSD General | 7 | 6th July 2008 10:00 PM |
| Source code of coreutils to create Incident Response Disk | audio | FreeBSD General | 6 | 5th July 2008 11:00 AM |