cat > clean<<EOF #!/bin/bash cd $(dirname $0) ls | grep -E ".(auc|log|aux|log|nav)$" | xargs rm -if {} EOF chmod +x clean