Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
~/testing $ echo Hello > hello.txt
~/testing $ echo Goodbye > goodbye.txt
~/testing $ cat goodbye.txt hello.txt > HELLO.txt
^C
~/testing $ ls -l
total 9056
-rw-r--r--  1 user  user        8 25 Jul 16:21 goodbye.txt
-rw-r--r--  1 user  user  4631048 25 Jul 16:22 hello.txt
~/testing $ 

Wha? I'm missing something here. Is there a destroy files insensitively option I'm missing? Why does this appear to loop?

share|improve this question
add comment

3 Answers 3

up vote 2 down vote accepted

Mac OS X by default uses a case-insensitive filesystem. If you want to change that you need to reformat your disk with the case-sensitive option. Be warned, that some programs written by major vendors <cough>Adobe</cough>, <cough>Microsoft</cough> have severe problems with case sensitive filesystems.

While the filesystem is case-insensitive all files will be presented as their natural case. I.e., if you have a file named hello.txt and type shift+HTab (capital H then tab) you will not get any completion candidates (unless you set your shell to do insensitive completion).

share|improve this answer
    
Things may be better now with Adobe & MS applications but they used to be completely unusable. E.g., a file written as Info.plist but opened as INFO.PLIST case sensitive will fail. It's been my experience that almost all Mac users (developers included) use case-insensitive so you're not likely to get much sympathy when you run into bugs. –  bahamat Jul 25 '12 at 20:57
    
I haven't encountered a case insensitive shell environment before. Thanks for the help... I'm going to have to re-think some of my shell-scripts now :-( –  mgjk Jul 25 '12 at 21:36
1  
@mgjk: Don't misunderstand. The shell is still case sensitive. The filesystem is not. It is a subtle, but important distinction. –  bahamat Jul 25 '12 at 22:47
add comment
cat goodbye.txt hello.txt > HELLO.txt

The sequence of events:

  1. The shell truncates hello.txt to zero bytes.
  2. cat writes the contents of goodbye.txt to stdout which points to hello.txt.
  3. cat starts reading from the hello.txt and writes what it reads to stdout, which is still pointing at hello.txt. Since cat is reading and writing the same file it will never reach the end of file and will continue adding to hello.txt until the filesystem is full.
share|improve this answer
add comment

The default option for formatting a disk in OSX is HFS+ Journaled case-insensitive. You will have to explicitly format as case-sensitive if you desire that behavior.

The behavior you are seeing is intended.

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.