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. Is this possible.

link|improve this question
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
feedback

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

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

3 Answers

up vote 7 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
link|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.stackoverflow.com/questions/98197/… – Jin Oct 7 '11 at 3:35
@Sosukodo: feel free to upvote now :) – sehe Oct 7 '11 at 8:54
feedback

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

$ 
link|improve this answer
feedback

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'
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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