Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
ls is great because it has very fast sorting by datetime, but the formatting is hard to deal with. I suggest using a token at --time-style like --time-style='+&%Y%m%d+%H%M%S.%N' where the token is '&', using that as reference you can further parse the output with sed so you can also backtrack as just before the token is the size! If someone want to post that as a complete answer, feel free to, I am too asleep right now :) – Aquarius Power Apr 16 at 6:39
up vote 35 down vote accepted

Why not use stat instead of ls?

stat -c "%y %s %n" *
share|improve this answer
This is nice, but it does have the "environment too large" /"argument list too long" problem potentially. – Mat Oct 7 '11 at 7:02
:-) Just a proof of concept. In Real Life[tm] this will be a find . -type f -print0 | xargs -0 stat -c "%y %s %n" – f4m8 Oct 13 '11 at 7:27
To format the output of stat, you can add width information to the format string like C printf function, e.g. "%y %8s %n", it's not documented, but seems works (coreutils 8.17, Fedora 18) – LiuYan 刘研 Apr 7 '13 at 7:47

You can get a lot of control about how you list files with the find utility. ls doesn't really let you specify the columns you want.

For example:

$ find . -maxdepth 1 -printf '%CY%Cm%Cd.%CH%CM\t%s\t%f\n'
20111007.0601   4096    .
20111007.0601   2   b
20111001.1322   4096    a

The argument to the printf action is a detailed in the manpage. You can choose different time information, what size you want (file size or disk blocks used), etc. You can also make this safe for unusual file names if further processing is needed.

share|improve this answer

You could always use another utility like awk to format the output of ls1:

/bin/ls -ls | awk '{print $7,$8,$9}'

1.Yes, generally, you shouldn't parse the output of ls but in this case the question specifically calls for it...

share|improve this answer
That doesn't print the file size though. And it only prints the first part of filenames with whitespace in them. And it can fail if ls is aliased (say alias ls='ls -i'). You really should take a lot of care if you want to go about parsing ls output. – Mat Oct 7 '11 at 6:16
I had the file size in there and then edited it out (vague moment) - I'll restore it. And I agree about all the caveats re parsing ls, but that is what the OP wanted... – jasonwryan Oct 7 '11 at 6:31
I disagree, the OP wants the filenames, not the first part of filenames if the filename happens to have whitespace. (Using /bin/ls would avoid the alias problem.) – Mat Oct 7 '11 at 6:34
That is understood implicitly: what is stated explicitly is that OP wants a solution with ls which we both agree is not going to satisfy the whitespace requirement. The /bin/ls suggestion is a good one. – jasonwryan Oct 7 '11 at 6:44

You can also use the 'date' command. It is very easy to use:

date -r [file name]

share|improve this answer

where space is defined as the separator and f6 means field 6

ls -lt | cut -d" " -f6-
share|improve this answer
it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5- – Aquarius Power Apr 16 at 6:37

You can pipeline two commands

ls -l|cut -d" " -f5
share|improve this answer
it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5- – Aquarius Power Apr 16 at 6:37

Your Answer


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.