LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   rename files[SOLVED] (https://www.linuxquestions.org/questions/linux-newbie-8/rename-files%5Bsolved%5D-832385/)

wademac 09-15-2010 02:20 PM

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!

TB0ne 09-15-2010 02:49 PM

Quote:

Originally Posted by wademac (Post 4098577)
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.

crts 09-15-2010 03:05 PM

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.

wademac 09-15-2010 09:49 PM

Quote:

Originally Posted by crts (Post 4098622)
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 :)

wademac 09-15-2010 09:57 PM

The answer to the statement (question) is

rename '_log-' '_log-srv3-' *

grail 09-15-2010 10:24 PM

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.

wademac 09-15-2010 10:50 PM

Quote:

Originally Posted by grail (Post 4098944)
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 :)


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