Some stylistic notes
- The
head -1syntax is obsolete in POSIX, replaced byhead -n 1. for filename in $(ls)is inefficient and will break on whitespace. You can use shell globbing for this instead, e.g.,for filename in *.- A lot of the variables seem to be inconsistently quoted. I recommend running ShellCheck on it, as this can be dangerous (if you set TMPDIR to
/tmp/ dir, I believe it will remove/tmpanddir)
all 3 comments