LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 07-17-2003, 06:10 PM   #1
whospeaks2me
LQ Newbie
 
Registered: Jul 2003
Posts: 1

Rep: Reputation: 0
Delete Empty files


hello everyone!!

how do i create a shell script that will delete any empty, regular files from the home directory. The script should not delete hidden files (even if they are empty).

thanks 100 times
 
Old 07-17-2003, 07:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Code:
#!/bin/bash
cd ~
find -type f -size 0b -iname "*" ! -iname ".*" -exec rm {} \;
If you don't trust me (and you shouldn't ;} trust
anyone, always test stuff) run it without the exec
bit, first, to make sure it only finds files you
REALLY want deleted....

Cheers,
Tink

P.S.: find rocks ;}
 
Old 07-18-2003, 11:39 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,005
Blog Entries: 11

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
And, did it work? :)

Cheers,
Tink
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete non-empty directories? Also have a terminal question Nylex Linux - General 10 07-16-2005 12:51 AM
how to search for and delete empty directories? BrianK Programming 4 06-03-2005 08:24 AM
smbfs files empty jthibodeau Linux - Networking 1 08-23-2004 03:58 PM
Certain FAT32 files become empty shoota Linux - General 2 11-07-2003 08:20 AM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 02:13 PM


All times are GMT -5. The time now is 08:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration