LinuxQuestions.org
Help answer threads with 0 replies.
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
  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
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
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, Arch
Posts: 3,793

Rep: Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086Reputation: 2086
Assuming bash:
Code:
for file in *{1023..1027}_*; do
  cat "$file" >> another-file
done
 
Old 04-04-2009, 07:42 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,378

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

Rep: Reputation: 244Reputation: 244Reputation: 244
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



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

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:23 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