Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question like this thread. How to rename multiple files by replacing word in file name?

My example is more complex than the above topic. The two variables are $name and $ newname getting from the shell script other location. $name and $ newname may have the unicode words or special symbles like []<>♫...etc,so could anyone help me to provide a method to add a part of script in shell scrit to solve file name replacing question.

BTW,I try to type two kind of commands to change the part of file name, but it can't work.

rename.ul '$name' '$newname' /home/fy6877/test/final/* 
ls /home/fy6877/test/final/|xargs -I$ rename.ul '$name' '$newname' $ 
share|improve this question
Giving us examples of $name and $newname would help – Iain Sep 29 '12 at 12:25

Use rename or mmv. Neither of them should care whether there are UTF-8-encoded unicode symbols in your names, or whether the arguments given on the command line are variables or plain literals. Make sure to pass arguments as "$name" not '$name' to ensure that the value of the variable gets passed to the rename command.

share|improve this answer
You are right, the variable format can't use by ' '. – fy6877 Sep 30 '12 at 3:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.