Matthias Schwarzott wrote: > Code may look like this: > > # get last one of sorted list > for t in $(ls -1 /usr/bin/gcc-3*|sort); do use teh globs, luke ;) for t in /usr/bin/gcc-3*; do # will already do this, sorting according to LC_COLLATE order (set to C or POSIX [same thing] for ebuild.) There's no need to step through every one either: t=(/usr/bin/gcc-3*); [EMAIL PROTECTED]: -1}; unset t # get rid of array storage (using same var for both, eg [EMAIL PROTECTED]: -1} only sets the first cell; the rest of the array is still live. var is a synonym for var[0] in BASH.)
set -- * t=${@: -1} # works here as well but dunno if that applies to all sh (the -1 expansion, not the set.) In any event not needed in BASH since arrays make our life so much easier ;) cf: /msg greybot ls and http://wooledge.org/mywiki/glob -- remember you can do, eg: for i in portage/*/*foo*/*.ebuild or a more common example: for f in */*/.jpg It's not find, but it is efficient and filename-safe. Regards, steveL. (Please, no complaints about not using spaces in filenames, there's no telling where your script could be used-- if it's written correctly. Subshells and externals as well; why fork and waste resources we don't have to?) -- gentoo-dev@lists.gentoo.org mailing list