LinuxQuestions.org
Review your favorite Linux distribution.
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 09-15-2010, 02:20 PM   #1
wademac
Member
 
Registered: Apr 2008
Posts: 37

Rep: Reputation: 15
rename files[SOLVED]


Hello all,

I have 3 load balanced servers srv1 srv2 srv3 (for example) and we did not change the log files to reflect the servers so all 3 servers have combined logs that have the same name and I wish for all logs be in the same folder for Urchin so they need all different names...so I need to rename the old logs to have the follow names

from : domain-combined_log-20100731.gz to domain-combined_log-srv1-120100731.gz

all logs follow the same structure with the domain-combined_log-date.gz

thanks!

Last edited by wademac; 09-15-2010 at 09:59 PM.
 
Old 09-15-2010, 02:49 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,218

Rep: Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474Reputation: 2474
Quote:
Originally Posted by wademac View Post
Hello all,

I have 3 load balanced servers srv1 srv2 srv3 (for example) and we did not change the log files to reflect the servers so all 3 servers have combined logs that have the same name and I wish for all logs be in the same folder for Urchin so they need all different names...so I need to rename the old logs to have the follow names

from : domain-combined_log-20100731.gz to domain-combined_log-srv1-120100731.gz

all logs follow the same structure with the domain-combined_log-date.gz

thanks!
Ok...now that you've told us what you WANT to do, what's your question/problem???

A very simple bash script can do this. If you don't know how to write one, there are many bash scripting tutorials you can find via Google that can get you started. if you get stuck, post what you've written, and where you're having a problem, and we can help.
 
1 members found this post helpful.
Old 09-15-2010, 03:05 PM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,604

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
In addition to what TB0ne said you could use LQ's search function. Renaming files is a common task. Have a look at those threads:

http://www.linuxquestions.org/questi...-files-831347/
http://www.linuxquestions.org/questi...lename-827305/
http://www.linuxquestions.org/questi...olders-804100/
http://www.linuxquestions.org/questi...751/page2.html

You will find useful info to get you started.
 
1 members found this post helpful.
Old 09-15-2010, 09:49 PM   #4
wademac
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by crts View Post
In addition to what TB0ne said you could use LQ's search function. Renaming files is a common task. Have a look at those threads:

http://www.linuxquestions.org/questi...-files-831347/
http://www.linuxquestions.org/questi...lename-827305/
http://www.linuxquestions.org/questi...olders-804100/
http://www.linuxquestions.org/questi...751/page2.html

You will find useful info to get you started.
thanks crts you rock This was a big help you are the very best
 
Old 09-15-2010, 09:57 PM   #5
wademac
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
The answer to the statement (question) is

rename '_log-' '_log-srv3-' *
 
Old 09-15-2010, 10:24 PM   #6
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,433

Rep: Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879Reputation: 1879
Well I am not sure about the asterix at the end, but if you have your solution you can mark the thread SOLVED by using the 'Thread Tools' menu option at the top of
your thread.
 
Old 09-15-2010, 10:50 PM   #7
wademac
Member
 
Registered: Apr 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by grail View Post
Well I am not sure about the asterix at the end, but if you have your solution you can mark the thread SOLVED by using the 'Thread Tools' menu option at the top of
your thread.
I gave it a test on the files and it worked great
 
  


Reply

Tags
logs, rename


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
Trouble with making a bash script to read in different files and rename output files. rystke Linux - Software 1 05-07-2009 08:00 AM
how to rename files bkcreddy17 Programming 7 09-14-2008 09:22 AM
rename files linux2man Linux - General 8 02-03-2007 05:26 AM
rename files allelopath Linux - General 5 07-05-2005 03:00 AM
Can not rename files. Maximus2000 Linux - General 0 04-22-2004 01:36 PM


All times are GMT -5. The time now is 11:30 PM.

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