0

I want to copy all files (included sub-folders) from $HOME directory to Desktop in bash. And as you know the Desktop is in $HOME. So, when I copy all files I get the message like this:

cannot copy a directory, '/home/adminuser/Desktop', into itself, '/home/adminuser/Desktop/'.

And I don't know the suitable code to exclude the folder Desktop. I use this: cp -r $HOME/* ~/Desktop/

Does anybody know a code for it or can anybody help me?

2 Answers2

1

Use rsync

rsync -av --progress $HOME/* $HOME/Desktop --exclude 'Desktop/'
1

You could do this using rsync:

rsync -avWxP --exclude Desktop /home/user/ /home/user/Desktop/
SYN
  • 2,863