Click the first file or folder you want to select. Hold down the Shift key, select the last file or folder, and then let go of the Shift key. Hold down the Ctrl key and click any other file(s) or folder(s) you would like to add to those already selected.
Using cp In this case, we get a list of files & folders to be copied using ls command, and use grep command to exclude files & folders. We pass this list to cp command for copying. Here exclusion is done by grep command and not cp command.
We can also use cp command to copy folders from one location to another excluding specific directories. Go your source directory i.e ostechnix in our case. The above command will copy all contents of the current folder ostechnix except the sub-directory dir2 and saves them to /home/sk/backup/ directory.
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
rsync has been my cp/scp replacement for a long time:
rsync -av from/ to/ --exclude=Default.png
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose increase verbosity
Simple, if src/
only contains files:
find src/ ! -name Default.png -exec cp -t dest/ {} +
If src/
has sub-directories, this omits them, but does copy files inside of them:
find src/ -type f ! -name Default.png -exec cp -t dest/ {} +
If src/
has sub-directories, this does not recurse into them:
find src/ -type f -maxdepth 1 ! -name Default.png -exec cp -t dest/ {} +
cp `ls | grep -v Default.png` destdir
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With