Let's say you have a file, foo.py that you are moving into a directory, call it /tmp. How can you change the filename without specifying anything in the mv command except a source file name and a destination directory?

This is kind of a trick question but it happened to me and caused problems. I'll post the answer if no one comes up with it.

link|improve this question
If you know the answer, why are you asking the question? – Keltari Aug 23 '11 at 16:14
6  
Welcome to Super User! I'm sorry, but this in not the kind of Jeopardy we want to play... – Tom Wijsman Aug 23 '11 at 16:20
2  
Answering your own question is encouraged. meta.stackoverflow.com/questions/12513/… I hope that people reading the question now will enjoy a little brain teaser, and then when the question is answered, everyone can learn. – Walter Nissen Aug 23 '11 at 16:21
@Walter Nissen Um, yeah, but I suggest that means if you ask a question for something that is currently giving you trouble AND THEN LATER find a solution do pop back and let us know - not that SU is a quiz site. – Linker3000 Aug 23 '11 at 16:27
1  
The issue here is that unless you stumble across the syntax by accident (where the question would actually be "Why does X rename my file as well as moving it?") what you have here isn't a real problem. What I propose would be a better question as it requires an explanation of what's going on. – ChrisF Aug 23 '11 at 17:47
show 3 more comments
feedback

closed as not a real question by Tom Wijsman, BloodPhilia, KronoS, grawity, Nifle Aug 23 '11 at 18:05

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. See the FAQ for guidance on how to improve it.

2 Answers

mv foo.py /tmp/

The last slash tells the mv command that it's a folder you want to move it to.

link|improve this answer
No, that is not the question. I am asking how you can have an unwanted side-effect that causes the filename to change! – Walter Nissen Aug 23 '11 at 16:16
feedback

Easy:

mv foo.py subdir/*

moves foo.py to dir 'subdir/' and renames it to '*'.

link|improve this answer
feedback

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