bugfindutils - Bugs: bug #20909, [wishlist] Alphabetic sort for find

 
 

bug #20909: [wishlist] Alphabetic sort for find

Submitted by:  Christopher Beland <beland>
Submitted on:  Sun 26 Aug 2007 09:06:54 PM UTC  
 
Category:  find Severity:  1 - Wish
Item Group:  None Status:  Works For Me
Privacy:  Public Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  4.2.29 Fixed Release:  None

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 10 Nov 2007 04:14:36 PM UTC, comment #4: 

Marking as "works for me" because there is already a simple solution to the problem that doesn't require find to change.

James Youngman <jay>
Project Administrator
Sat 08 Sep 2007 07:30:04 PM UTC, comment #3: 

$ find directory[12] -type f | sort | sed 's_.*/__'
a
c
e
b
d
f

James Youngman <jay>
Project Administrator
Sat 08 Sep 2007 03:52:40 PM UTC, comment #2: 

To clarify, if I have the following files:

/directory1/a
/directory1/e
/directory1/c
/directory2/b
/directory2/f
/directory2/d

The desired output would be:

a
c
e
b
d
f

But piping to "sort" I would get:

a
b
c
d
e
f

Christopher Beland <beland>
Sat 08 Sep 2007 03:17:26 PM UTC, comment #1: 

You should indeed be able to pipe the file name list to sort.     You don't provide enough specific information for me to guess at what you mean by "alphabetize regardless of originating directory".  

However, were I forced to guess, I would suggest that you simply have locale settings in operation which define a collation order which doesn't meet your requirements.  If that is the case, you just need to change your locale setting to something that suits your needs better.  You might find the Texinfo documentation for sort helpful for this (see the first footnote).

James Youngman <jay>
Project Administrator
Sun 26 Aug 2007 09:06:54 PM UTC, original submission:  

I recently needed to pass the output of "find" to a script that took in relative pathnames (for example, the part of the filename not including the directory path).  Due to the number of files, it would have been quite convenient, when examining the output of the script, to have the input sorted alphabetically within a given directory.  Since "find" was accessing multiple directories in this run, I could not simply pipe the output through "sort", since this would alphabetize regardless of originating directory, and mix the filenames of multiple directories together, which would be considerably less convenient.

It would be handy for this and perhaps other cases, to have an option for "find" to sort the contents of a directory alphabetically, as is the default behavior with "ls".  "ls" is unfortunately not a convenient replacement for this particular case, since it does not have some of the other sophisticated options that "find" does.

Christopher Beland <beland>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jay (Posted a comment)
  • -email is unavailable- added by beland (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2007-11-10 jay StatusNone => Works For Me
        Open/ClosedOpen => Closed
    2007-09-08 jay Severity3 - Normal => 1 - Wish

    Back to the top


    Powered by Savane 3.5