Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to rename a file with a name that contains the "/" character. Example:

mv product.dat product/2012.dat

Is this possible in Unix?

share|improve this question
    
Such a file can't exist (/ separates directories and files in paths), so you can't. –  vonbrand Jan 23 '13 at 19:14
add comment

3 Answers

Are you saying you want to remove the '/' or add it? To remove it (however the heck it got there), use single quotes.

If you are trying to add it, then no, you cannot and should not.

share|improve this answer
add comment

A / isn't allowed as a character in a file or directory name under Unix. The / is understood as punctuation between directory levels in a complete path. What you can do is create a directory called product, then move your file into it (which could be what you actually intended anyway.)

mkdir product
mv product.dat product/2012.dat
share|improve this answer
add comment

I don't know any Unix with a filesystem that supports a / character in a filename. / is used to separate path entries, so it cannot be used in a filename.

share|improve this answer
    
You can mount FAT filesystems. OK, you still can't use /, but that's not because of the filesystem. –  Isaac Rabinovitch Nov 29 '12 at 21:28
1  
@Isaac: I'm afraid to disagree. FAT doesn't support / in filenames regardless of what OS is used to mount it. In particular, As soon as it supported subdirectories, MS-DOS internally accepted / as a path separator as a synonymous of the documented ``. –  jlliagre Nov 30 '12 at 7:04
    
@jlliagre Don't be afraid to disagree, especially when you're right. –  Isaac Rabinovitch Nov 30 '12 at 18:02
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.