If I were to ask you to mention a command to copy a folder to another location, almost everyone would mention cp.
Now, if I tell you that in addition, you must copy all the content of that folder except 1 file, many would be left thinking, and others would mention Rsync, then with the parameter –Exclude you can exclude X file or folder and not copy it. But ... did you know that cp also allows you to do this? ... O_O … Yes friends, cp has its own "exclude" hehe.
For example, we have the folder isos containing: ubuntu.iso, debian.iso y archlinux.iso : And it happens that we want to copy to the other folder (distros-deb, which is empty) the file debian.iso y ubuntu.iso, that is, all except archlinux.iso
For this we could copy a file and then another, manually, but it is much smarter to use the options that the system offers us, right? … 😀… for example, to do this just:
cp isos/!(archlinux.iso) distros-deb/
And this is enough to copy EVERYTHING contained in the isos directory to distros-deb, everything except archlinux.iso 😉
But suppose we not only have those 3 files, but we also have fedora.iso and chakra.iso ... and we want to do the same, it would also be excluded from the copy fedora.iso and chakra.iso, let's see how to do it:
cp isos/!(archlinux.iso|fedora.iso|chakra.iso) distros-deb/
As you can see, several files or folders can be excluded, we only separate them by a pipe (|) and matter resolved 😀
By this I do not mean that cp is better for everything than rsync ... but, both are excellent tools, for example ... did you know the parameter -u de cp? ... hehe, sure not 😉
Well, nothing more to add ... is this an interesting tip? 😀