LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-04-2009, 12:00 AM   #1
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Rep: Reputation: 15
copying between interval


Hi

when I issue "ls -lrt" I see that there are too many logfiles.
What I want to do is copy some logs from this place to another file.

For example:

ls -lrt

.
.
.
.
******1023***
******1024***
******1025***
******1026***
******1027***
.
.
.
.

I want to copy logs from 1023 to 1027 to another file.
How can i do that?
 
Old 04-04-2009, 12:48 AM   #2
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536Reputation: 536
More specifics may help you get a more specific answer, but:

Code:
for stuff in 1023 1024 1025 1026 1027; do
echo -e "`cat $stuff`" >> another-file
done;
 
Old 04-04-2009, 02:06 AM   #3
scofiled83
Member
 
Registered: Nov 2008
Posts: 70

Original Poster
Rep: Reputation: 15
Hmmm
The filenames are something like:

acrabdbad1023_danjnad
dffrabdat1024_bnchski
...
...
...

Does it again work?
and
Do I need to specify the all number? There might be quite a lot,Can I just specify the first and last ones.
For examaple:
1023...1027 (something like that)

because it might be 1023 to 1100.
 
Old 04-04-2009, 09:36 AM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 1,421

Rep: Reputation: 360Reputation: 360Reputation: 360Reputation: 360
Assuming bash:
Code:
for file in *{1023..1027}_*; do
  cat "$file" >> another-file
done
 
Old 04-04-2009, 07:42 PM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.2, Centos 5.8
Posts: 11,740

Rep: Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905Reputation: 905
Maybe you should look into logrotate ?
 
Old 04-04-2009, 08:34 PM   #6
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,695
Blog Entries: 5

Rep: Reputation: 237Reputation: 237Reputation: 237
Quote:
Originally Posted by ntubski View Post
Assuming bash:
Code:
for file in *{1023..1027}_*; do
  cat "$file" >> another-file
done
Code:
cat *{1023..1027}_*  >> another_file
 
  


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
Using grep with interval expression... Chikne Slackware 2 04-13-2007 11:04 AM
Log netstat at interval DaHoe Linux - Newbie 4 11-06-2006 02:11 AM
Sendmail, interval between mailsending? godzern Linux - General 1 05-02-2006 04:48 PM
hid interval patch some Linux - Newbie 5 12-04-2003 06:28 AM
Programmable Interval Timers saintt Linux - General 0 10-19-2001 08:50 AM


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