Created
February 5, 2016 16:26
-
-
Save ftessier/19c844127a9aeb598481 to your computer and use it in GitHub Desktop.
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 | |
# usage display | |
usage() { | |
echo -e "\nPlease provide at least one simulation basename." | |
echo -e "\nUSAGE:\n$(basename $0) [ basename1 basename2 ... ]\n" | |
} | |
# check if there is at least one argument | |
if [ $# -lt 1 ]; then | |
usage | |
exit 1 | |
fi | |
# simulation base names | |
names=("$@") | |
# loop over all names | |
for name in "${names[@]}"; do | |
# echo current name | |
echo "CLEANING ${name} ..." | |
# loop over file extensions | |
for ext in lock eo mederr; do | |
# remove files | |
count=$( find -maxdepth 1 -name "${name}.${ext}" | wc -l ) | |
if [ $count -gt 0 ]; then | |
for f in ${name}.${ext}; do | |
(set -x; \rm $f) | |
done | |
fi | |
done | |
# remove work files | |
count=$( find -maxdepth 1 -name "${name}_w*" | wc -l ) | |
if [ $count -gt 0 ]; then | |
echo "+ rm ${name}_w*" | |
\rm ${name}_w* | |
fi | |
# remove egsrun directories | |
count=$( find -maxdepth 1 -name "egsrun_*_${name}_*" | wc -l ) | |
if [ $count -gt 0 ]; then | |
echo "+ rm egsrun_*_${name}_*" | |
\rm -r egsrun_*_${name}_* | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment