nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Shell script to Give free space on hard disk & propose a list of files to be delete

This is a discussion on Shell script to Give free space on hard disk & propose a list of files to be delete within the Shell scripting forums, part of the Development/Scripting category; Hello everybody! This is my first time having to write a script so your help is most appreciated.Also i am ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-05-2009, 08:14 PM
Junior Member
User
 
Join Date: May 2009
OS: openSUSE 11.1
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
manike is on a distinguished road
Default Shell script to Give free space on hard disk & propose a list of files to be delete

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:
Code:
#! /bin/bash
clear
df -h
exit

Last edited by nixcraft; 30-05-2009 at 09:27 PM.
Reply With Quote
  #2 (permalink)  
Old 30-05-2009, 09:31 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

df will only list free space on the system. To list top 10 space eating files in current directory, enter:
Code:
ls -lSh . | head -10
To suggest only filename, enter:
Code:
ls -lSh . | head -10  | awk '{ print $8}' | sed '/^$/d'
ls -lSh /var | head -10  | awk '{ print $8}' | sed '/^$/d'
Another option is find command:
Code:
find /var -type f -ls | sort -k 7 -r -n | head -10
See How do I find the largest top 10 files and directories on a Linux / UNIX / BSD filesystem?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Aggregation of Hard disk space of different PCs sanjit_sahu Linux software 1 22-04-2009 01:41 PM
Creating the perl Backup script for hard disk to hard disk backup vmr.gouda CentOS / RHEL / Fedora 2 15-05-2008 01:08 AM
Shell script to check the disk space on remote systems vijayscripts Shell scripting 5 21-10-2007 06:29 PM
script for free space of hard drive zafar466 Shell scripting 1 16-01-2007 08:33 PM


All times are GMT +5.5. The time now is 11:33 AM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38