LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 12-08-2006, 03:55 AM   #1
Gurr
LQ Newbie
 
Registered: Jun 2006
Location: Pretoria
Distribution: Fedora Core 4
Posts: 5

Rep: Reputation: 0
Unix rm files of same size


Hi all,

I'm looking for a way to remove all files of the same
size in one directory, in this case 0bytes.

$>rm...

Thanks in advance!
 
Old 12-08-2006, 04:03 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
find -size 0 -exec rm {} \;
 
Old 12-08-2006, 05:15 AM   #3
Gurr
LQ Newbie
 
Registered: Jun 2006
Location: Pretoria
Distribution: Fedora Core 4
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks for response.

Quote:
find -size 0 -exec rm {} \;
- searches subdirectories as well and removes the matches.

Quote:
for i in `ls`; do if [ -s $i ]; then echo $i data; else rm $i; fi; done
- found this that only removes in current directory and not subdirectories.

----
 
Old 12-08-2006, 05:22 AM   #4
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
find /<path>/<to>/<directory> -size 0 -exec rm {} \;

should also restrict the search to the named directory.
 
  


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
Linux/Unix Command to find RAM size? ssnkumar Linux - General 9 09-09-2009 10:38 AM
How to increase command line Arguments Size in UNIX/LINUX??? sunilvadranapu General 10 03-31-2009 12:47 PM
how to create header files in unix? nid_ice@yahoo.co.in Programming 2 06-30-2005 12:21 AM
How to search and delete files in Unix/Linux puzz_1 Linux - General 5 04-09-2004 11:35 AM
increase point size size when printing PDF files newlin Red Hat 0 09-27-2003 08:13 AM


All times are GMT -5. The time now is 07:59 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration