Friday, June 18, 2010

Ubuntu - Copy Everything Except

If you want to copy everything within a directory, except certain files or directories, you can use the following command.
cp -a `ls | grep -v yourexcludepattern` ../destinationdir/

Assume, you want to copy all files, except *.java within from the current directory to the foo directory. Then, the command would be,
cp -a `ls | grep -v *.java` /home/wageesha/foo

2 comments: