LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 01-29-2006, 07:31 AM   #1
carl0ski
Member
 
Registered: Sep 2004
Location: Melbourne, Victoria Australia
Distribution: Support those that support you :)
Posts: 872
Blog Entries: 12

Rep: Reputation: 30
list directory only show newest file amarok*


hi

im hoping to list a directory

but i want to extract the newest file name only

ls -t -1 $zipname*
amarok01-11.zip
amarok12-28.zip
amarok21-28.zip
amarok01-28.zip


amarok01-11.zip
was the last created how can i snatch it?


thanks
 
Old 01-29-2006, 10:31 AM   #2
MensaWater
Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,028
Blog Entries: 5

Rep: Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791Reputation: 791
ls -tr1 $zipname* |tail -1
-or-
ls -t1 $zipname* |head -1


The -r tails it to reverse sort order. The -1 option for ls means single column not single file. tail -1 says show only the last line (reversed sort order the last line would be the newest) and head -1 says show only the first line (normal order the first line would be the newest).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Amarok play list auto continue? david.dales Linux - Software 5 11-22-2005 02:40 AM
Sama SUSE 10 beta 4 doesnt show windows complete file list 1kyle Suse/Novell 0 09-09-2005 06:59 AM
Copying the newest file in a directory to another location Transition Linux - General 2 01-14-2005 12:53 PM
How to list total file size of a directory phil1076 Linux - General 3 12-18-2003 04:47 PM
List the contents of a directory to a file MasterC Linux - General 19 11-26-2002 11:09 AM


All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration