Skip to content

Instantly share code, notes, and snippets.

@jkglasbrenner
Created June 10, 2018 21:53
Show Gist options
  • Save jkglasbrenner/fc346d59b3d3834198ddc283fa8ab0ca to your computer and use it in GitHub Desktop.
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
#!/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