linux merge two folders

I found this little trick using tar years ago in an early revision of the O'Reilly book "Running Linux":

First cd to the source directory, then do this:

tar cf - . |(cd /targetdir; tar xvf -)

This is an amazing command: All it once, it creates a tar to standard input, then changes to the target directory and un-tars it on-the-fly. Since it is tar, it maintains all permissions and timestamps, etc. Any existing files in the target would not be affected unless they had the same names, in which case they would be overwritten. But you could tweak the tar switches to change that behavior. I use this all the time. Take care of the syntax: that's a "dash" or minus character after the 'cf', and then the dot character, for current directory. then the pipe character, etc.

Reference -

Chatopera 研发团队 聊天机器人 机器学习 智能客服 北京华夏春松科技有限公司:为企业交付智能客服系统、智能对话机器人、机器人客服、Chatbot。
已标记关键词 清除标记