I want to list and delete auxiliary files created by LaTeX at compilation, in the current directory.
Here is the code:
#!/bin/bash
#
# clean auxiliary files generated by LaTeX compilations
#
shopt -s nullglob
# LaTeX auxiliary file list
files=(*.{log,aux,dvi,lof,lot,bit,idx,glo,bbl,bcf,ilg,toc,ind,out,blg,fdb_latexmk,fls,run.xml,synctex.gz})
if [[ ${#files[@]} -ne 0 ]]; then
ls --color=auto "${files[@]}"
[[ "$(read -e -p "Delete ${#files[@]} files? (y/N): "; echo $REPLY)" == [Yy]* ]] && rm -f "${files[@]}" || echo 'Nothing done.'
else
echo 'Nothing to do.'
fi
Is there a more bash idiomatic way?