Super User is a question and answer site for computer enthusiasts and power users. 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

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

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

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .