Created
June 10, 2018 21:53
-
-
Save jkglasbrenner/fc346d59b3d3834198ddc283fa8ab0ca to your computer and use it in GitHub Desktop.
Simple command to knit rmarkdown documents via a make command in directories found using pattern matching
This file contains hidden or 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 | |
| # | |
| # Simple command to knit rmarkdown documents via a make command in directories | |
| # found using pattern matching | |
| ############################################################################### | |
| # Global parameters | |
| ############################################################################### | |
| readonly args="${@:1}" | |
| ############################################################################### | |
| # Run a make command in directories found using pattern matching | |
| # | |
| # Globals: | |
| # None | |
| # Arguments | |
| # 1: directory_pattern # required | |
| # 2: output_file # required | |
| # Returns | |
| # None | |
| ############################################################################### | |
| _compile_projects () { | |
| local directory_pattern="$1" | |
| local output_file="$2" | |
| find \ | |
| `pwd` \ | |
| -name "${directory_pattern}" \ | |
| -type d \ | |
| -print0 \ | |
| | xargs \ | |
| -0 \ | |
| -I % \ | |
| sh -c \ | |
| "cd %;make ${output_file}" | |
| } | |
| ############################################################################### | |
| # Main script | |
| ############################################################################### | |
| _compile_projects ${args} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment