Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 01-29-2006, 06:31 AM   #1
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*


im hoping to list a directory

but i want to extract the newest file name only

ls -t -1 $zipname*
was the last created how can i snatch it?

Old 01-29-2006, 09:31 AM   #2
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 6,945
Blog Entries: 14

Rep: Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163Reputation: 1163
ls -tr1 $zipname* |tail -1
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).


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 01:40 AM
Sama SUSE 10 beta 4 doesnt show windows complete file list 1kyle SUSE / openSUSE 0 09-09-2005 05:59 AM
Copying the newest file in a directory to another location Transition Linux - General 2 01-14-2005 11:53 AM
How to list total file size of a directory phil1076 Linux - General 3 12-18-2003 03:47 PM
List the contents of a directory to a file MasterC Linux - General 19 11-26-2002 10:09 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:39 PM.

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