Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Style question: Can this be written in a more elegant way?
- X-seq: zsh-users 10173
- From: "Com MN PG P E B Consultant 3" <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>
- To: "zsh-users Mailinglist" <zsh-users@xxxxxxxxxx>
- Subject: Style question: Can this be written in a more elegant way?
- Date: Mon, 24 Apr 2006 09:26:47 +0200
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Thread-index: AcZncHIDfJLTU4boTOScshxoftzkLQ==
- Thread-topic: 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