The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
finding difference between 2 directory recursively yayati Shell Programming and Scripting 2 04-09-2008 07:37 AM
Finding the oldest file in a particular directory pavan_movva Shell Programming and Scripting 2 10-07-2006 02:17 AM
Finding largest file in current directory? AusTex High Level Programming 1 03-13-2005 10:03 AM
finding file in a directory legato UNIX for Dummies Questions & Answers 4 01-24-2005 08:27 PM
Finding users currently accesing a directory mehtad Shell Programming and Scripting 3 11-29-2001 12:34 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-06-2008
Registered User
 

Join Date: Feb 2008
Posts: 8
Finding the lowest sequenced file in a directory?

Hello,

I have three files in a directory:


1_700_123456.lst
1_701_123456.lst
1_702_123456.lst





I am trying to use a command via ksh that will list the file that has the lowest number in the second node and put that to a file.

In the example above, it would put 1_700_123456.lst in a file.



Any ideas on how to do this easily?



Thanks!
Reply With Quote
Forum Sponsor
  #2  
Old 06-06-2008
Registered User
 

Join Date: Oct 2007
Location: USA
Posts: 568
Code:
ls -l | sort -t_ -nk2,2 | head -1
Reply With Quote
  #3  
Old 06-06-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Try something like this:

Code:
awk -F"_" '!m || $2<m{m=$2;s=$0}END{print s}' file
Regards
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0