[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: OT - Bourne shell array sort



Tod wrote:
Without having to write my own, is there a quick way I can sort a two dimensional array on a specific column? Of course if there's a list that might be better to post this question to I'd appreciate that as well.


Thanks - Tod



Ok, poorly formed question.  I know about sort, the -k option was the
first thing I thought of.

Here's an example:

#!/bin/sh

SONGS=`find /mnt/music -type f`


I know at a certain position in the directory structure there is an artist, a song, a title, and an album name. I could use -k along with -t to specify a sort on delimiter like:

SONGS=`find /mnt/music -type f |sort -t '/' -k 5,5`

What I was wondering is if I could do this against the SONG array on the fly, or if I needed to rerun the find, pumping it through sort with different parameters each time. I'm sure there's a better way but I'm blind to it at the moment.

Sorry for bad post, just looking for a quick answer from a large experience base. Thanks for the feedback.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]