I have a folder 'foo' that contains a lot of sub folders, e.g.
foo |---20101 |---20102 |---20103 |---20111 |---20112 |---20113
There are way more than this, but hopefully it explains the scenario. I now want to copy all folders from this folder that start '2011' into a sibling of 'foo' called 'bar'. However, 'bar' already contains some folders with the same name
bar |---20111 |---20113 |---20114
The contents of the source and destination folder should be merged. Notice that the script will also need to create a bar/20112 folder as that doesn't exist.
I'm new to Mac Terminal scripting and have successfully managed to grep the right folders
foo>ls | grep ^2011
Which lists the right folders, but I've no idea how to pipe that over to an appropriate copy operation.