version problem in bash

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Jeremy C. Reed
Date:  
Subject: version problem in bash
On Thu, 23 Oct 2003, Nathan England wrote:

> But I've also added smaller things, so I made smaller revisions using 1.1 and
> 1.2 upto 1.9 then going to 2.0
>
> Well, my problem is, now I'm up to 4.1.4 and I want to use a script to grab
> the newest file, grep something out of it, and exit. I want to know the
> fastest way for bash to figure out the newest version (biggest number?) and
> use that one.


The built-in test can check for newer files and can compare if a string
sorts after another string ("lexicographically in the current locale").

Maybe something like:

big="" ; for fn in * ; do [ "$fn" \> "$big" ] && big="$fn" ; done ; echo $big


Jeremy C. Reed
http://www.reedmedia.net/