Created
March 27, 2017 19:54
-
-
Save stefco/4df6e7b3d0f2588658355945566cd6c0 to your computer and use it in GitHub Desktop.
Little GNU/Linux shell scripts for finding MATLAB code dependencies real quick 'n dirty
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
# find filenames of MATLAB functions called in a given script or function; call | |
# from the MATLAB working directory where functions are defined. takes the | |
# script to be searched as its argument. | |
matlab-files-called () { | |
if (! [ $# -eq 1 ]) || [ "$1"c = -hc ]; then | |
echo "ERROR: 1 argument required" | |
echo "Usage: matlab-files-called MATLAB_Script_To_Search.m" | |
return 1 | |
fi | |
find . -maxdepth 1 -iname '*.m' \ | |
| xargs -n1 basename \ | |
| sed 's/\.m$//' \ | |
| xargs -i grep -o '\<'{}'\> *(' "$1"\ | |
| sort \ | |
| uniq \ | |
| sed 's/ *($/.m/;/'"$1"'/d' | |
} | |
matlab-files-called-recursive () { | |
if (! [ $# -eq 1 ]) || [ "$1"c = -hc ]; then | |
echo "ERROR: 1 argument required" | |
echo "Usage: matlab-files-called-recursive MATLAB_Script_To_Search.m" | |
return 1 | |
fi | |
for f in matlab-files-called "$1"; do | |
matlab-files-called-recursive "$f" | |
done \ | |
| sort \ | |
| uniq | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment