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'm using Ubuntu 10 and I'm quickly finding out that it's case sensitive when it's inconvenient for it to be so (like when autocompleting file paths with tab in terminal) but also case INsensitive when using the MV and CP commands (also inconvenient when trying to duplicate a filename with a different case).

In essence, I need this command to work but it doesn't.

cp ./filename.txt ./FileName.txt

I just end up with filename.txt:

enter image description here

How can I get the same file with a different case but same name in the same directory?

EDIT: Maerics' comment below helped me remember that I'm actually developing on a Windows shared drive running NTFS which is case INsensitive. This is why even though CP and MV don't generate an error, the file isn't copied (or more likely IS copied, but Windows replaces the already existing one).

share|improve this question

migrated from stackoverflow.com Jun 1 '12 at 8:16

This question came from our site for professional and enthusiast programmers.

1  
That's strange : I tested this command without surprise... I have no problem with different cases in the same directory. –  dystroy May 31 '12 at 19:18
4  
Note that this behavior may depend on the type of filesystem on which these files exist. For example, FAT32 may not differentiate these filenames. –  maerics May 31 '12 at 19:23
    
WOW. This was the answer Maerics. The files are stored on a mounted drive which is running NTFS. I completely forgot since I'm developing cross platform that I'm using Windows to store the files. –  advocate May 31 '12 at 19:25
1  
@advocate: NTFS is case-sensitive, so you should be able to mount it the way you like. However, the question is whether this is what you want :) –  0xC0000022L May 31 '12 at 19:57
    
Testing is showing that Windows 7 doesn't appear to be case sensitive. –  advocate May 31 '12 at 22:50

4 Answers 4

up vote 7 down vote accepted

You can enable case-insensitive file name completion in bash by adding the following line to $HOME/.inputrc:

set completion-ignore-case On

Regarding the file names: This depends on the file system. On Linux file systems, there should be no problem. On other file systems, the behavior can be controlled with options to the mount command. See the manual page mount(8) for more information on the available options to mount.

share|improve this answer
    
You are correct. The underlying file system wasn't a Linux filesystem so while CP and MV work, Windows chooses to keep the already existing file (when overriding because of case INsensitivity) case which makes it appear in Unix terminal like the command didn't work at all. Also, thanks for the completion ignore case, that will help a lot! –  advocate May 31 '12 at 19:31

Ubuntu is not partially case sensitive. It's always case sensitive. filename.txt and Filename.txt are two different files and can be placed in the same directory. So this command:

cp ./filename.txt ./FileName.txt

will work without any problem in the same directory.

share|improve this answer
    
It doesn't though. I've been trying to figure it out for the last hour. –  advocate May 31 '12 at 19:19
2  
may be, you don't have filename.txt itself in ur current directory? –  Blue Moon May 31 '12 at 19:20
    
It's definitely in there. –  advocate May 31 '12 at 19:22
    
Maerics above helped me solve the problem. I'm developing in Ubuntu a windows -> linux port but the files are stored on the Windows computer and I forgot I had the drive mounted. The underlying NTFS was preventing both files from existing at the same time. –  advocate May 31 '12 at 19:27
2  
I saw Maerics comment. thx –  Blue Moon May 31 '12 at 19:28

Is this a property of the filesystem or something else?

pa-ubuntu-11388$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 10.04.3 LTS
Release:        10.04
Codename:       lucid
pa-ubuntu-11388$ ls -l
pa-ubuntu-11388$ touch filename.txt
pa-ubuntu-11388$ ls -l
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 filename.txt
pa-ubuntu-11388$ cp ./filename.txt ./FileName.txt
pa-ubuntu-11388$ ls -l
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 FileName.txt
-rw-r--r-- 1 dshawley dev 0 May 31 15:17 filename.txt

It works fine for me.

share|improve this answer
    
Maerics above helped me solve the problem. I'm developing in Ubuntu a windows -> linux port but the files are stored on the Windows computer and I forgot I had the drive mounted. The underlying NTFS was preventing both files from existing at the same time. –  advocate May 31 '12 at 19:28

NTFS and VFAT are not case-sensitive, they are just case-preserving. That means if you create a file named FileName.txt, the file system will preserve the mixed case name, but you can access the file with whatever case combination of the same letters, like FILENAME.TXT, filename.txt or fileNAME.txt. This explains you cannot have two files with the same spelling with only a variation of upper/lower case in the same directory.

SMB exported file system have to implement this behavior not to confuse Windows clients.

ZFS can be configured to behave that way with the casesensitivity=mixed property.

share|improve this answer

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.