LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-07-2006, 07:34 AM   #1
brazilian_user
Member
 
Registered: Nov 2005
Location: Brazil, Poá - São Paulo
Distribution: Debian Etch
Posts: 110

Rep: Reputation: 15
Removing files...


Hello All!

I have a big directory with lots of files on it. I'd like to know how Can I remove
files through it date.

For example:

-rw------- 1 test rodrigo 1060864 Jul 27 14:11 mm.20881.mem
-rw------- 1 test rodrigo 0 Jul 27 14:11 mm.20881.sem
-rw------- 1 test rodrigo 1060864 Jul 28 17:28 mm.2092.mem
-rw------- 1 test rodrigo 0 Jul 28 17:28 mm.2092.sem
-rw------- 1 test rodrigo 1060864 Jul 28 17:28 mm.2095.mem
-rw------- 1 test rodrigo 0 Aug 28 17:28 mm.2095.sem
-rw------- 1 test rodrigo 1060864 Aug 27 14:13 mm.20973.mem

Imagine there are 3 hundreds of files like those above, it were created on July and
August, How can I delete only the July files??

Thank You!
 
Old 08-07-2006, 07:53 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

There is more then one way of doing this, this came to mind first:

ls -l | awk '/ Jul / { print $9 }'

The above will give you all the files in July, to remove them add the following:

ls -l | awk '/ Jul / { print $9 }' | xargs rm

The above will fail if: filename(s) have special characters in them (spaces, to name just one).

Hope this helps.
 
Old 08-07-2006, 08:11 AM   #3
brazilian_user
Member
 
Registered: Nov 2005
Location: Brazil, Poá - São Paulo
Distribution: Debian Etch
Posts: 110

Original Poster
Rep: Reputation: 15
Thumbs up

Fantastic!!!

Hi druuna,

I've been reading a shell script book "Programação Shell Linux",
it is one of the best here in Brazil, there is a chapter about AWK,
I've read it about twice but I don't know Why I'm getting some difficulties
to understand it. Now I'm seeing this command is very important, I'll read it again.

Thank You very much!
 
Old 08-07-2006, 08:19 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

If you like books (I do) then this one is 'a must':

O'reilly's Sed & Awk.

Both sed and awk are explained, from the basics to more advanced topics.
 
Old 08-07-2006, 08:57 AM   #5
brazilian_user
Member
 
Registered: Nov 2005
Location: Brazil, Poá - São Paulo
Distribution: Debian Etch
Posts: 110

Original Poster
Rep: Reputation: 15
I'll you take a look at it. It seems to be good, it's not easy to find out
books talking about specific topics like this one, thank's for your
suggestion.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
removing files kjs Linux - Software 1 02-17-2005 02:18 PM
removing fglrx files? ryedunn Linux - Hardware 1 01-17-2005 12:21 PM
Removing files wihtout removing containing Direcotry caps_phisto Linux - General 2 10-07-2004 08:16 AM
Removing tar.gz files nixdisciple Linux - General 2 07-03-2002 10:55 PM
Removing files ascii2k Linux - General 2 11-26-2001 11:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:33 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
Open Source Consulting | Domain Registration