Created
January 27, 2015 00:50
-
-
Save rpherrera/8c888ec8c08b42a7ceeb to your computer and use it in GitHub Desktop.
Selective Merge Directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BASE_DIR='/home/base' | |
PRIMARY_DIR='/home/primary' | |
SECONDARY_DIR='/home/secondary' | |
mkdir -p ${BASE_DIR} | |
pushd ${BASE_DIR} | |
find ${PRIMARY_DIR} -type d | cut -d '/' -f 7- | grep '/' | while read nested_directory; do | |
mkdir -p ${nested_directory} | |
pushd ${nested_directory} | |
find ${PRIMARY_DIR}/${nested_directory} -type f -exec ln -s {} . \; | |
find ${SECONDARY_DIR}/${nested_directory} -type f -exec ln -s {} . \; | |
popd | |
done | |
find ${PRIMARY_DIR} -type d | cut -d '/' -f 7- | grep '/' | while read nested_directory; do | |
pushd ${nested_directory} | |
ls -1 * | wc -l | |
popd | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment