Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

For example, I want to rename tif/fat/tul/codes/MyCode.pl to TheCode.pl in the same directory. Currently I know these:

mv tif/fat/tul/codes/MyCode.pl tif/fat/tul/codes/TheCode.pl

, which requires me to repeat typing the full path (can be annoying if the path is quite long) or

cd mv tif/fat/tul/codes/
mv MyCode.pl TheCode.pl

The drawback being I have to type 2 commands, and there is a side-effect of changing the current directory (which can be undesirable in many cases)

Is there a more efficient way to do this?

share|improve this question
1  
This should answer your question: superuser.com/questions/298081/… –  Glutanimate Apr 14 '13 at 10:45
add comment

2 Answers

Another thing you can do is open another shell (like bash) in your current one, cd to the directory of the file, and then mv. Then you just move back to your previous directory with Ctrl+D

share|improve this answer
add comment
find /path/to/dir/ -iname MyCode.pl -execdir mv MyCode.pl TheCode.pl

/path/to/dir is path of directory in which you want to rename files.

Note: This will rename all files in directory /path/to/dir/ and its subdirectory.

share|improve this answer
add comment

Your Answer

 
discard

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.