LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 07-17-2003, 05: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, 06:05 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
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, 10:39 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,950
Blog Entries: 11

Rep: Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860Reputation: 860
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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-15-2005 11:51 PM
how to search for and delete empty directories? BrianK Programming 4 06-03-2005 07:24 AM
smbfs files empty jthibodeau Linux - Networking 1 08-23-2004 02:58 PM
Certain FAT32 files become empty shoota Linux - General 2 11-07-2003 07:20 AM
How to delete the destination files while the source files deleted in cp -u ? myunicom Linux - General 4 09-26-2003 01:13 PM


All times are GMT -5. The time now is 09:00 AM.

Main Menu
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