Hello All ,
I have one query :
Operating System : Linux OS
Activity : Copy multiple folders with * but exclude some folders during copy from source path to destination path .
Scenario :
In this path "/tmp/abc/"
folders list
def
ghi
jkl
mno
xyz
while using "cp -r * /tmp/test-path" but exclude "mno" folder .
if possible any command exclude command while using 'cp' copy command then please provide command & example .
I am waiting for your valuable help .
I hope you understand my query & scenario .
Thank you ,
Jeesshnasree
I don't think you can do this with `cp` but `rsync` should do it. Something like:
`rsync -a --exclude=/dir/to/ignore /path/to/copy /path/to/destination`
`-a` copies recursively and preserves file attributes. You can add `-v` to get more verbose output.
Have a look at `man rsync` for more details.
NB: I haven't tested this specific command so try it out on a test dir first.
Hope this helps.
If you want to copy a directory but exclude certain files or directories within it, you can use the rsync command with the –exclude option...! Here is the sample command:
rsync -av --exclude 'dir1' sourcedir/ destinationdir/
Thanks
Red Hat
Learning Community
A collaborative learning environment, enabling open source skill development.