Listmates, Every time a new fglrx driver comes out, I end up dorking with my script for automating the install from the ATi binary to try and improve it. Tonight is no different. The task: "I may have several versions of the fglrx rpm in the directory where the script is running or in /usr/src/packages/RPMS/.. and I want the script to automatically select the latest one to install. Such as (names for testing purposes only): -rw-r--r-- 1 david dcr 21355823 2008-08-22 21:08 fglrx64_7_1_0_SUSE110-8.522-1.x86_64.rpm -rw-r--r-- 1 david dcr 0 2008-08-22 23:47 fglrx64_7_1_0_SUSE110-8.523-1.x86_65.rpm -rw-r--r-- 1 david dcr 0 2008-08-22 23:47 fglrx64_7_1_0_SUSE110-8.524-1.x86_66.rpm Specifically what I need help solving is "what is the best way to select the newest fglrx rpm from the present directory to install?" I can do it 3 different ways, but all rely on file creation time (ls -t) and seem horribly inefficient. Using the version number would seem to be a better way. So far I have: (1) Grab the first filename from $(ls -t fglrx*.rpm) with a for loop: mcount=1 for i in $(ls -t fglrx*.rpm); do if [ "$mcount" -eq "1" ]; then FGLRX_RPM="$i" echo -e "\n\t\tSelecting: $FGLRX_RPM\n" let "mcount+=1" fi done This seems like a giant waste of a loop. (2) Grab it using sed to delete everything after the first whitespace: FGLRX_RPM=$(echo $(ls -t fglrx*.rpm) | sed -e 's/\s.*//' -e 's/\s*$//') This is a cludge and I want to eliminate the pipe and the sed call (3) Dump the dir list into an array and grab the first element: RPM_ARRAY=( $(ls -t fglrx*.rpm) ) FGLRX_RPM=${RPM_ARRAY[0]} This is better, but it still seems clumsy. There has to be a better way to do this. How can I pull the version information from the filename itself and take the highest version regardless of the file time information? I can't figure out how to parse the version fields in the filename after I have the directory list of fglrx files without adding more sed calls and more loop. I'd pull the version info like this: fglrx64_7_1_0_SUSE110-8.522-1.x86_64.rpm ^^^^^ out of what is returned by $(ls -t fglrx*.rpm) and use that to select the file? Is it a reasonable approach or will it be more inefficient? What says the brain trust? -- David C. Rankin, J.D., P.E. Rankin Law Firm, PLLC 510 Ochiltree Street Nacogdoches, Texas 75961 Telephone: (936) 715-9333 Facsimile: (936) 715-9339 www.rankinlawfirm.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org