set -x function fix_content_root() { local in_directory="$1" local targets=($(grep -E -l --include \*.iml '##g' ${target}; sed -i '//{:a;N;/<\/content>/!ba};//d' ${target}; sed -i '//{:a;N;/<\/content>/!ba};//d' ${target}; sed -i '//{:a;N;/<\/content>/!ba};//d' ${target}; done } fix_content_root "${HOME}/Documents/IdeaProjects"