BASH copy all files except one

Joe Cannatti picture Joe Cannatti · Aug 21, 2009 · Viewed 87.6k times · Source

I would like to copy all files out of a dir except for one named Default.png. It seems that there are a number of ways to do this. What seems the most effective to you?

Answer

Jon picture Jon · Aug 21, 2009

Should be as follows:

cp -r !(Default.png) /dest

If copying to a folder nested in the current folder (called example in the case below) you need to omit that directory also:

cp -r !(Default.png|example) /example