Greg Hewgill (ghewgill) wrote,
Greg Hewgill
ghewgill

stupid unix tricks

I just did the following, intending to copy the contents of the ../other directory to the current directory:

$ cp ../other/*

Notice the missing . at the end of the command? In my case, there were exactly two files in the other directory. This command doesn't do anything like what you might expect it to do. Instead, it copies the contents of ../other/file1 over the top of the contents of ../other/file2 (because the shell expands the wildcard before cp sees it), destroying file2 in the process. Gah!

As it happens, I luckily had the original file2 open in an editor session so I simply saved it again. The irony of this situation was that I was preparing to add those files to a new Subversion repository so I wouldn't accidentally lose them.

Subscribe

  • 2013 in review

    2013 is the year when everything changed. The biggest event was the birth of our daughter Lily. She was born prematurely in Shanghai while we…

  • 2012 in review

    2012 has been fairly quiet. Maybe it just seems that way because I haven't actually written anything new in this blog since last year's annual…

  • new photo galleries

    I've been busy processing photo galleries from the last year (or two) and putting them online for your perusal. Vancouver 2010 Northland…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments