UNIX_MISTAKE
Pitfalls in UNIX


UNIX_MISTAKE, a document which discusses some mistakes that the UNIX operating system seems to foster.

Languages:

HTML_MISTAKE is available in a C version and a FORTRAN77 version and a FORTRAN90 version and an HTML version and a MATLAB version and a UNIX version.

Unix is prone to obscure and irreversible errors, such as what happens when you accidentally type

        rm * .c
      

Today, I invented a new error. I had two files in one directory, and I wanted to have a copy of both somewhere else. My Ubuntu interface tries to make everything easy, but one thing it can't handle, (or I can't figure out) is how to copy a file. Believe it or not, there are menu items to COPY and COPY TO but neither one seems to actually...copy the damn file.

So I moved both files temporarily to the Desktop, since that's easy to specify on a command line. The files are julia_gpu.cu and julia_cpu.cu. Since their names are similar, it's going to be easy to copy both of them to my current directory with a single command. But instead of typing:

        cp ~/Desktop/julia* .
      
I typed
        cp ~/Desktop/julia*
      
which, as you must realize, is not quite the same thing.

No files were copied to my current directory. In fact, nothing at all happened, or so it seemed. Then I realized that I should have received a snarly Unix message about not specifying a destination for the copy command...so the fact that I didn't get an error message meant that Unix thought it knew what I wanted...and that meant that my actual command had been expanded to the perfectly-reasonable-to-Unix:

        cp ~/Desktop/julia_cpu.cu ~/Desktop/julia_gpu.cu
      
and so one of my files overwrote the other, and now I have two copies of one file and no copies of the other. I'm just lucky that I realized what had happened, and in this case knew where another copy of the obliterated file could be retrieved. That doesn't always happen!

All in all, it's kind of a beautiful error, and only works if there are exactly two matches to the pattern.

If I could figure out how to make money from an error like this, I'd be filling in the patent form right now!

You can return to the HTML web page.


Last revised on 26 February 2017.