This worked for me without the temporary text files. for f in *m4a; do if test \! -f "${f%%.m4a}.mp3"; then echo "$f exists, but ${f%%.m4a}.mp3 does not."; fi; done Works for me using bash and zsh, your mileage may vary if you use a different shell. ~Kyle