Last active
November 11, 2015 18:17
-
-
Save Willshaw/615086649c254a3952bc to your computer and use it in GitHub Desktop.
Copy hook into multiple repos
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
ls -la | awk '{print $9}' | grep -v comcar | egrep '^[a-z]' | while read -r line; do sed -e "s/myrepo/$line/" myrepo/hooks/post-receive > $line/hooks/post-receive; done | |
# | |
# Break down of the above command is below - don't try to run the bits | |
# on their own, you need to pipe the outputs between, like the example above | |
# | |
# List contentsfiles in current directory - full list view, row per file/folder | |
ls -la | |
# Only print the 9th column (folder name) | |
awk '{print $9}' | |
# Ignore (-v) the "myepo" folder, that's the one we are copying from | |
grep -v myrepo | |
# Filter list to ignore hidden folders (e.g. the . and .. at the start of ls -a) | |
egrep '^[a-z]' | |
# loop over the lines | |
while read -r line; | |
# do text replacement of "myrepo" for the value of the current line. | |
# we're replacing the contents of myrepo/hooks/post-receive with | |
# the subsituted (sed) value and creating the $line/hooks/post-receive file... | |
do sed -e "s/myrepo/$line/" myrepo/hooks/post-receive > $line/hooks/post-receive; | |
# then we end the while loop | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment