![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| remove empty directory | sirrtuan | Shell Programming and Scripting | 7 | 04-09-2009 12:41 AM |
| Transfer files wih directory structure. | uxlunatick | SCO | 11 | 04-28-2008 03:25 PM |
| copy files with directory structure | adddy | UNIX for Dummies Questions & Answers | 3 | 12-11-2006 08:50 AM |
| MV files from one directory structure(multiple level) to other directory structure | srmadab | UNIX for Advanced & Expert Users | 4 | 09-13-2006 04:01 PM |
| disk space used for files with in a directory structure. | kasala | Shell Programming and Scripting | 8 | 01-14-2005 04:26 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Script to remove all empty files within the directory structure?
Hi I need to write a shell script which basically searches for all the empty files within the directory structure, lists them before asking the user to confirm if they would like to delete them. If the user deletes the file then a notice would appear confirming the file is deleted.
I've be trying to do this for weeks now and its driving me mad, I'm quite new to this, although I am getting to grips with it slowly. Cheers |
|
||||
|
Thanks for the reply m8.
I don't think I explained what I was trying to do correctly, I'm trying to create a shell script that will allow me to find all empty files within my directory tree, list them and then give me the option of deleting them. I would like to be able to get the option of deleting them in the format of : delete word.doc y/n? :> y word.doc deleted. I know some files that are empty are not to be deleted this is why I need to see what I am about to get rid of. I'm just strating out doing Linux and I've hit a brick wall with this so any help would be appreciated, cheers. Last edited by cat123; 06-05-2008 at 06:56 AM.. |
|
||||
|
This pseudo code may put you on right lines...
Code:
file_names=`find . -name "*.*" -size 0c` for i in $file_names do print "Do you want to delete the file?" read input if ans='y' or 'Y' rm -f $i else #do nothing echo "File not deleted" fi done |
|
||||
|
cheers guys for the help, im gonna give it a go and I'll let you's know how I do.
Cheers |
| Sponsored Links | ||
|
|