Re: OT - Bourne shell array sort

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

 



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.


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux