- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Sort order of files in "find" results
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:12 PM
05-17-2005 10:12 PM
find . -name "STATS*" -exec abc.sh {} \;
the files are returned in an order not expected. I expect them to be returned in an alphabetic order.
The STATS* files have a date eg:
STATS20050203.txt
STATS20050201.txt
STATS20050202.txt
It seems as if they are returned in a date/time last updated order instead of "alphabetic" order (i.e. date order for the purposes of the abc.sh script).
ls -l does return them in the expected order.
How do I rectify this?
Thanks
Carlo
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:17 PM
05-17-2005 10:17 PM
Re: Sort order of files in "find" results
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:24 PM
05-17-2005 10:24 PM
Re: Sort order of files in "find" results
find . -name "STATS*" -exec abc.sh {} \; | sort
first:
$PATH variable has to have . included to execute it with out full path name or ./
second:
If you are abc.sh is going executing sorted files then it will be a problem more.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:27 PM
05-17-2005 10:27 PM
Re: Sort order of files in "find" results
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2005 10:35 PM
05-17-2005 10:35 PM
Re: Sort order of files in "find" results
find . -name "STATS*" | sort | xargs -i ./abc.sh {}
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2005 02:26 AM
05-18-2005 02:26 AM
Re: Sort order of files in "find" results
Example-
$ mkdir newdir
$ cd newdir
$ touch c b a
$ find . -print
.
./c
./b
./a
$ rm b
$ touch d
$ find . -print
.
./c
./d
./a
Notice the first find displayed the names in the order they were created. But when I deleted file "b" and created "d", it put "d" in the slot where "b" was.
The reason ls lists the files sorted by filename is because ls does an internal sort.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2005 06:21 AM
05-18-2005 06:21 AM
Re: Sort order of files in "find" results
return its results in any particular
order, because the underlying directory
structure doesn't guarantee any particular
order, either. If you want the "find"
results to be in some order
(time/alpha/size/etc.) you MUST sort them
yourself, typically using "sort".