Register
It is currently Fri Apr 18, 2014 4:14 pm

Help with linux bash script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Sat May 30, 2009 7:11 am   

Joined: Sat May 30, 2009 6:42 am
Posts: 2
Hello everybody!

This is my first time having to write a script so your help is most appreciated.Also i am a beginner when it comes to linux so please bare with me.Thanks in advance to all who will look into this for me.

I have to write a bash script that will show the free space on the hard disk and also to generate/propose a list of files to be deleted to free up space.
So far the part that shows the free space on the hard disk can be solved using the "df" command.As for the part with generating/proposing the list of files to be deleted i don't know how to proceed.

This is what I have so far:

#! /bin/bash
clear
df -h
exit


Top
 Profile  
 PostPosted: Sun May 31, 2009 5:23 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
Well the easy solution is something like this.

[/code]
#!/bin/bash
clear
df -h

for i in $(df -h | awk {'print $6'} | grep -v Mounted); do
find $i -size 100M
done
[code]

This thou will work somewhat wierd since / will print _all_ files that are above 100Mb and the it'll print the individual partitions.

You can solve this by adding a
| grep -v "^\/"
after Mounted.

But then all the files on the root partition won't show.

Hope this gives you a pointer.

Best Regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Mon Jun 01, 2009 12:27 pm   

Joined: Sat May 30, 2009 6:42 am
Posts: 2
thanks...i will try it out.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP