Copying files around is probably one of the most common reasons why we create bash files. We could be using unix
cp
but there are more powerful ways available.
The script below will take all the ./src-folder content and recreate it in the ./dist-folder while keeping the original folder structure .
rsync -avr ./src-folder/ ./dist-folder/
Now one of the biggest advantages of rsync is that you can use it to copy files across servers. Interesting isn’t it? Make sure to check our guide here:
How to copy files across servers using rsync
Found this article useful? Leave us a thumbs up.