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 04-23-2009, 11:58 AM   #1
unim21
LQ Newbie
 
Registered: Apr 2009
Posts: 11

Rep: Reputation: 0
Finding multiple files with ascending numerical files extensions


Greetings all,

I've recently been tasked with writing a smart script that can grab binlog files from MySQL, tar/gzip them and then be able to recognize which files it has already grabbed and then move onto the next chunk of log files.

For instance,

#ls -al
file.001
file.002
file.003
file.004
file.inded
file.005
file.006
etc

I need to be able to find/locate files 00x through 00x, and leaving out any 00x file that isn't listed in my parameters.

Thus far I haven't found a way to do this using Find.

Any suggestions?
 
Old 04-23-2009, 12:05 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
Hi,

You can use regular expressions when using find: find . -type f -iname "file.00[0-5]" should give back file.000 - file.005 (if they actually exist).

Hope this helps.
 
Old 04-23-2009, 01:25 PM   #3
unim21
LQ Newbie
 
Registered: Apr 2009
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks! That solved my issue.
 
Old 04-23-2009, 08:50 PM   #4
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
In the long run you'd probably be better off using the logrotate facility for that kind of work.
 
  


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
when finding files in Konqueror, why use the files index? newbiesforever Linux - General 4 03-20-2009 10:06 AM
Finding files and then finding content within those files... Maeltor Linux - Software 5 03-13-2007 01:06 PM
Find files with different extensions cdog Linux - Software 2 03-09-2007 04:38 PM
files extensions BillyF General 4 02-17-2007 06:17 PM
Finding multiple files with different extensions ExoZagNoid Linux - Newbie 1 01-18-2006 04:33 AM


All times are GMT -5. The time now is 12:53 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration