Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 03-19-2010, 02:02 AM   #1
Registered: Oct 2008
Posts: 48

Rep: Reputation: 16
ls command

Hi all,
How do I list only access time and file name? For example if I do ls -l --sort=time then
# ls -l --sort=time
total 3
-rw-rw-rw- 1 nobody nobody   21476 2010-03-18 22:30 file1
-rw-rw-rw- 1 nobody nobody   21499 2010-03-18 22:29 file2
-rw-rw-rw- 1 nobody nobody   21397 2010-03-18 22:28 file3
I just want to display like this
2010-03-18 22:30 file1
2010-03-18 22:29 file2
2010-03-18 22:28 file3
Thanks in advance.
Old 03-19-2010, 03:02 AM   #2
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Stretch (Fluxbox WM)
Posts: 1,389
Blog Entries: 52

Rep: Reputation: 355Reputation: 355Reputation: 355Reputation: 355
One way is to use a filter to cut out the earlier columns. You could use cut, although the listing format varies depending on the length of the owner/group names, and the field delimiter is not a single character.

Or you could use awk or perl, eg:
ls -l --sort=time | perl -lane 'print "@F[5..@F]"'
The '-a' flag causes perl to autosplit the fields, so you can then print out fields from 5 onwards.

Last edited by neonsignal; 03-19-2010 at 03:03 AM.
Old 03-19-2010, 04:06 AM   #3
Senior Member
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,275

Rep: Reputation: 148Reputation: 148
Check the output
#ls -lt
If you need reverse order while sorting
#ls -lrt

Last edited by kirukan; 03-19-2010 at 04:07 AM.
Old 03-19-2010, 07:03 AM   #4
LQ Newbie
Registered: Mar 2010
Location: London
Distribution: Ubuntu
Posts: 16

Rep: Reputation: 1
If you mean access time and not modification time, then you'll have to use the 'u' flag, otherwise you'll sort on modification time:
\ls -ltu | perl -lane 'print "@F[5..@F]"'
Old 03-19-2010, 10:43 AM   #5
Registered: Feb 2010
Location: Raleigh, NC
Posts: 83

Rep: Reputation: 22
ls -lt | grep -v "total" | awk '{print $(NF-2) " " $(NF-1) " " $NF}'

Last edited by jwl17330536; 03-19-2010 at 10:46 AM.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
My error in mkisofs command to make a command line iso mg92865 Linux - Newbie 1 06-20-2008 11:43 AM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 02:23 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:33 AM.

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