Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I use ls in linux to get a listing of filenames date and size only? I don't need to see the other info such as owner, permission.

share|improve this question

migrated from stackoverflow.com Oct 7 '11 at 3:45

This question came from our site for professional and enthusiast programmers.

1  
Not a programming question. Try unix.stackexchange.com. –  Matt Ball Oct 7 '11 at 3:25
    
which Linux are we talking about? –  tolitius Oct 7 '11 at 3:25
    
apache server.. –  Pinkie Oct 7 '11 at 3:30

4 Answers 4

up vote 12 down vote accepted

ls -l | awk '{print $5, $6, $7, $9}'

This will print the file size in bytes, month, date, and filename.

jin@encrypt /tmp/foo % ls -l
total 0
drwxr-xr-x  2 jin  wheel  68 Oct  4 12:43 bar
drwxr-xr-x  2 jin  wheel  68 Oct  4 12:43 baz
drwxr-xr-x  2 jin  wheel  68 Oct  4 12:43 quux

jin@encrypt /tmp/foo % ls -l | awk '{print $5, $6, $7, $9}'
68 Oct 4 bar
68 Oct 4 baz
68 Oct 4 quux
share|improve this answer
    
What's the policy on up voting a non-programming question's answer? :-) –  Sosukodo Oct 7 '11 at 3:33
    
@Sosukudo Yeah, I'm not sure either. But people seem to agree that it's ok to downvote bad questions but not the answers if they're useful. meta.stackexchange.com/questions/98197/… –  Jin Oct 7 '11 at 3:35
    
@Sosukodo: feel free to upvote now :) –  sehe Oct 7 '11 at 8:54

you can always do:

$ ls -l
total 0
-rw-r--r--  1 user  staff  0 Oct  6 23:29 file1
-rw-r--r--  1 user  staff  0 Oct  6 23:29 file2
-rw-r--r--  1 user  staff  0 Oct  6 23:30 file3
-rw-r--r--  1 user  staff  0 Oct  6 23:30 file4
-rw-r--r--  1 user  staff  0 Oct  6 23:30 file5
-rw-r--r--  1 user  staff  0 Oct  6 23:30 file6
-rw-r--r--  1 user  staff  0 Oct  6 23:30 file7

cut it to:

$ ls -l | cut -f 8-13 -d ' '

0 Oct  6 23:29 file1
0 Oct  6 23:29 file2
0 Oct  6 23:30 file3
0 Oct  6 23:30 file4
0 Oct  6 23:30 file5
0 Oct  6 23:30 file6
0 Oct  6 23:30 file7

$ 
share|improve this answer

Technically, it's not possible with ls, but find can do the same job with its -printf switch:

find -maxdepth 1 -printf '%t %s %p\n'
share|improve this answer

Slight variation on tolitius

ls -lh | cut -f 6- -d ' '
share|improve this answer
    
Care to explain what the variation adds? –  Ivo Flipse Jul 9 '12 at 11:37
    
Just removes the need to specify the number of the end field by using the 6- in stead of 6-x –  zzapper Jul 9 '12 at 13:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.