LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 03-19-2010, 03:02 AM   #1
nodopro
Member
 
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
Code:
# 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
Code:
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, 04:02 AM   #2
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Jessie (Fluxbox WM)
Posts: 1,388
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:
Code:
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 04:03 AM.
 
Old 03-19-2010, 05:06 AM   #3
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,274

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

Last edited by kirukan; 03-19-2010 at 05:07 AM.
 
Old 03-19-2010, 08:03 AM   #4
Zuulie
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:
Code:
\ls -ltu | perl -lane 'print "@F[5..@F]"'
 
Old 03-19-2010, 11:43 AM   #5
jwl17330536
Member
 
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 11:46 AM.
 
  


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 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 02: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 03:14 AM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 07:30 PM
My error in mkisofs command to make a command line iso mg92865 Linux - Newbie 1 06-20-2008 12:43 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 03:23 AM


All times are GMT -5. The time now is 10:06 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration