Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Style question: Can this be written in a more elegant way?



Problem: In a directory, perform a certain operation PROG_SUCCESS on the
newest file
matching the glob pattern X*. If no file exists with this glob pattern,
execute PROG_FAIL.

Here is my solution:

file=$(ls -1t X* 2>/dev/null|head -n 1)
if [[ ${#file} -gt 0 ]]
then
  PROG_SUCCESS $file
else
  PROG_FAIL
fi

This certainly works, and I think it's not that bad either. Just
wondering whether
this can be written less clumsy. Any suggestions?

Ronald
-- 
Ronald Fischer (phone +49-89-63676431)
mailto:mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author