Linux ls to show only filename date and size












54














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




















  • 1




    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 '16 at 6:39


















54














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




















  • 1




    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 '16 at 6:39
















54












54








54


12





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















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?







linux command-line files ls






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 7 '11 at 4:07









Mat

38.9k8117125




38.9k8117125










asked Oct 7 '11 at 3:33









Pinkie

373135




373135








  • 1




    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 '16 at 6:39
















  • 1




    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 '16 at 6:39










1




1




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 '16 at 6:39






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 '16 at 6:39












9 Answers
9






active

oldest

votes


















83














Why not use stat instead of ls?



stat -c "%y %s %n" *





share|improve this answer



















  • 1




    This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
    – Mat
    Oct 7 '11 at 7:02






  • 4




    :-) 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








  • 5




    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












  • Because with ls I can output it with a thousand separator char. How does it work with stat?
    – Al Bundy
    Mar 17 at 15:43










  • I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
    – MS Berends
    Aug 8 at 20:15



















27














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%CMt%st%fn'
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





















  • Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
    – guettli
    Dec 1 '16 at 9:47










  • Wish this worked on macs.
    – Jerinaw
    Jul 17 at 17:31










  • lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
    – Pierluigi Vernetto
    Sep 28 at 8:06



















18














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



















5














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




date -r [file name]







share|improve this answer























  • Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
    – guettli
    Dec 1 '16 at 9:38



















1














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



ls -lt | cut -d" " -f6-





share|improve this answer



















  • 1




    it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
    – Aquarius Power
    Apr 16 '16 at 6:37



















1














If you wish to use ls, but preserve proper size, you can use:



ls -Ss1pq --block-size=1





share|improve this answer





























    -1














    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 '16 at 6:37



















    -1














    The simplest answer is to use



     ls -1


    notice that it is a one not an l. This works on Ubuntu, showing only the name of the times.






    share|improve this answer

















    • 1




      Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
      – Alexander Batischev
      Jul 31 '17 at 16:46










    • What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
      – skrewler
      Feb 11 at 5:29





















    -3














    ls -s1 returns file size and name only on AIX, not sure about Linux






    share|improve this answer

















    • 2




      Can you explain how/why you believe this answers the question?
      – Scott
      Jun 13 '17 at 20:04











    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f22218%2flinux-ls-to-show-only-filename-date-and-size%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    9 Answers
    9






    active

    oldest

    votes








    9 Answers
    9






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    83














    Why not use stat instead of ls?



    stat -c "%y %s %n" *





    share|improve this answer



















    • 1




      This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
      – Mat
      Oct 7 '11 at 7:02






    • 4




      :-) 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








    • 5




      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












    • Because with ls I can output it with a thousand separator char. How does it work with stat?
      – Al Bundy
      Mar 17 at 15:43










    • I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
      – MS Berends
      Aug 8 at 20:15
















    83














    Why not use stat instead of ls?



    stat -c "%y %s %n" *





    share|improve this answer



















    • 1




      This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
      – Mat
      Oct 7 '11 at 7:02






    • 4




      :-) 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








    • 5




      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












    • Because with ls I can output it with a thousand separator char. How does it work with stat?
      – Al Bundy
      Mar 17 at 15:43










    • I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
      – MS Berends
      Aug 8 at 20:15














    83












    83








    83






    Why not use stat instead of ls?



    stat -c "%y %s %n" *





    share|improve this answer














    Why not use stat instead of ls?



    stat -c "%y %s %n" *






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Apr 7 '13 at 4:19









    Andrew Marshall

    1,535196




    1,535196










    answered Oct 7 '11 at 6:50









    f4m8

    1,23985




    1,23985








    • 1




      This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
      – Mat
      Oct 7 '11 at 7:02






    • 4




      :-) 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








    • 5




      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












    • Because with ls I can output it with a thousand separator char. How does it work with stat?
      – Al Bundy
      Mar 17 at 15:43










    • I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
      – MS Berends
      Aug 8 at 20:15














    • 1




      This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
      – Mat
      Oct 7 '11 at 7:02






    • 4




      :-) 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








    • 5




      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












    • Because with ls I can output it with a thousand separator char. How does it work with stat?
      – Al Bundy
      Mar 17 at 15:43










    • I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
      – MS Berends
      Aug 8 at 20:15








    1




    1




    This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
    – Mat
    Oct 7 '11 at 7:02




    This is nice, but it does have the "environment too large" /"argument list too long" problem potentially.
    – Mat
    Oct 7 '11 at 7:02




    4




    4




    :-) 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






    :-) 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






    5




    5




    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






    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














    Because with ls I can output it with a thousand separator char. How does it work with stat?
    – Al Bundy
    Mar 17 at 15:43




    Because with ls I can output it with a thousand separator char. How does it work with stat?
    – Al Bundy
    Mar 17 at 15:43












    I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
    – MS Berends
    Aug 8 at 20:15




    I don’t see how this answers the question?! It’s a nice outside the box solution, but you’d lose all benefits from ls. What about colours??
    – MS Berends
    Aug 8 at 20:15













    27














    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%CMt%st%fn'
    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





















    • Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
      – guettli
      Dec 1 '16 at 9:47










    • Wish this worked on macs.
      – Jerinaw
      Jul 17 at 17:31










    • lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
      – Pierluigi Vernetto
      Sep 28 at 8:06
















    27














    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%CMt%st%fn'
    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





















    • Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
      – guettli
      Dec 1 '16 at 9:47










    • Wish this worked on macs.
      – Jerinaw
      Jul 17 at 17:31










    • lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
      – Pierluigi Vernetto
      Sep 28 at 8:06














    27












    27








    27






    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%CMt%st%fn'
    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 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%CMt%st%fn'
    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












    share|improve this answer



    share|improve this answer










    answered Oct 7 '11 at 4:50









    Mat

    38.9k8117125




    38.9k8117125












    • Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
      – guettli
      Dec 1 '16 at 9:47










    • Wish this worked on macs.
      – Jerinaw
      Jul 17 at 17:31










    • lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
      – Pierluigi Vernetto
      Sep 28 at 8:06


















    • Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
      – guettli
      Dec 1 '16 at 9:47










    • Wish this worked on macs.
      – Jerinaw
      Jul 17 at 17:31










    • lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
      – Pierluigi Vernetto
      Sep 28 at 8:06
















    Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
    – guettli
    Dec 1 '16 at 9:47




    Above input to find ('%CY%Cm%Cd.%C...') is long. At least GNU find has %C+ (output "2016-08-29+10:57:56.9201257840") and %Cc (output "Mo 29 Aug 2016 10:57:56 CEST")
    – guettli
    Dec 1 '16 at 9:47












    Wish this worked on macs.
    – Jerinaw
    Jul 17 at 17:31




    Wish this worked on macs.
    – Jerinaw
    Jul 17 at 17:31












    lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
    – Pierluigi Vernetto
    Sep 28 at 8:06




    lovely, and if you want to print just the full path and size, this should work "find /path/to/ -printf '%h/%f %sn'"
    – Pierluigi Vernetto
    Sep 28 at 8:06











    18














    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
















    18














    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














    18












    18








    18






    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














    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














    share|improve this answer



    share|improve this answer








    edited Oct 7 '11 at 6:47

























    answered Oct 7 '11 at 5:09









    jasonwryan

    49.1k14134184




    49.1k14134184












    • 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


















    • 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
















    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






    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 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




    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




    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











    5














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




    date -r [file name]







    share|improve this answer























    • Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
      – guettli
      Dec 1 '16 at 9:38
















    5














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




    date -r [file name]







    share|improve this answer























    • Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
      – guettli
      Dec 1 '16 at 9:38














    5












    5








    5






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




    date -r [file name]







    share|improve this answer














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




    date -r [file name]








    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Feb 18 '14 at 13:40









    Anthon

    60.2k17102163




    60.2k17102163










    answered Feb 18 '14 at 13:16









    Ankit Khare

    15112




    15112












    • Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
      – guettli
      Dec 1 '16 at 9:38


















    • Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
      – guettli
      Dec 1 '16 at 9:38
















    Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
    – guettli
    Dec 1 '16 at 9:38




    Nice, this was new to me. Unfortunately it does not work for several files via globbing: date -r foo*.txt --> date: extra operand "foo2.txt"
    – guettli
    Dec 1 '16 at 9:38











    1














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



    ls -lt | cut -d" " -f6-





    share|improve this answer



















    • 1




      it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
      – Aquarius Power
      Apr 16 '16 at 6:37
















    1














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



    ls -lt | cut -d" " -f6-





    share|improve this answer



















    • 1




      it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
      – Aquarius Power
      Apr 16 '16 at 6:37














    1












    1








    1






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



    ls -lt | cut -d" " -f6-





    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














    share|improve this answer



    share|improve this answer








    edited Oct 15 '13 at 16:07









    Anthon

    60.2k17102163




    60.2k17102163










    answered Oct 15 '13 at 15:49









    zzapper

    709513




    709513








    • 1




      it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
      – Aquarius Power
      Apr 16 '16 at 6:37














    • 1




      it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
      – Aquarius Power
      Apr 16 '16 at 6:37








    1




    1




    it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
    – Aquarius Power
    Apr 16 '16 at 6:37




    it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
    – Aquarius Power
    Apr 16 '16 at 6:37











    1














    If you wish to use ls, but preserve proper size, you can use:



    ls -Ss1pq --block-size=1





    share|improve this answer


























      1














      If you wish to use ls, but preserve proper size, you can use:



      ls -Ss1pq --block-size=1





      share|improve this answer
























        1












        1








        1






        If you wish to use ls, but preserve proper size, you can use:



        ls -Ss1pq --block-size=1





        share|improve this answer












        If you wish to use ls, but preserve proper size, you can use:



        ls -Ss1pq --block-size=1






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 24 at 17:37









        Deep

        111




        111























            -1














            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 '16 at 6:37
















            -1














            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 '16 at 6:37














            -1












            -1








            -1






            You can pipeline two commands



            ls -l|cut -d" " -f5





            share|improve this answer














            You can pipeline two commands



            ls -l|cut -d" " -f5






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 24 '15 at 11:22









            jimmij

            30.8k870105




            30.8k870105










            answered Dec 24 '15 at 11:19









            Deepak

            9




            9












            • it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
              – Aquarius Power
              Apr 16 '16 at 6:37


















            • it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
              – Aquarius Power
              Apr 16 '16 at 6:37
















            it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
            – Aquarius Power
            Apr 16 '16 at 6:37




            it failed because ls uses spaces for indentation and sometimes it is -f6- other times it is -f5-
            – Aquarius Power
            Apr 16 '16 at 6:37











            -1














            The simplest answer is to use



             ls -1


            notice that it is a one not an l. This works on Ubuntu, showing only the name of the times.






            share|improve this answer

















            • 1




              Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
              – Alexander Batischev
              Jul 31 '17 at 16:46










            • What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
              – skrewler
              Feb 11 at 5:29


















            -1














            The simplest answer is to use



             ls -1


            notice that it is a one not an l. This works on Ubuntu, showing only the name of the times.






            share|improve this answer

















            • 1




              Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
              – Alexander Batischev
              Jul 31 '17 at 16:46










            • What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
              – skrewler
              Feb 11 at 5:29
















            -1












            -1








            -1






            The simplest answer is to use



             ls -1


            notice that it is a one not an l. This works on Ubuntu, showing only the name of the times.






            share|improve this answer












            The simplest answer is to use



             ls -1


            notice that it is a one not an l. This works on Ubuntu, showing only the name of the times.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 31 '17 at 16:26









            episodeyang

            11




            11








            • 1




              Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
              – Alexander Batischev
              Jul 31 '17 at 16:46










            • What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
              – skrewler
              Feb 11 at 5:29
















            • 1




              Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
              – Alexander Batischev
              Jul 31 '17 at 16:46










            • What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
              – skrewler
              Feb 11 at 5:29










            1




            1




            Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
            – Alexander Batischev
            Jul 31 '17 at 16:46




            Welcome to StackOverflow! Please read the questions more carefully: the person was asking to list date and size, not just names.
            – Alexander Batischev
            Jul 31 '17 at 16:46












            What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
            – skrewler
            Feb 11 at 5:29






            What version of ubuntu? I tried several recent versions and for each: -1 list one file per line
            – skrewler
            Feb 11 at 5:29













            -3














            ls -s1 returns file size and name only on AIX, not sure about Linux






            share|improve this answer

















            • 2




              Can you explain how/why you believe this answers the question?
              – Scott
              Jun 13 '17 at 20:04
















            -3














            ls -s1 returns file size and name only on AIX, not sure about Linux






            share|improve this answer

















            • 2




              Can you explain how/why you believe this answers the question?
              – Scott
              Jun 13 '17 at 20:04














            -3












            -3








            -3






            ls -s1 returns file size and name only on AIX, not sure about Linux






            share|improve this answer












            ls -s1 returns file size and name only on AIX, not sure about Linux







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jun 13 '17 at 18:54









            cacflyer

            1




            1








            • 2




              Can you explain how/why you believe this answers the question?
              – Scott
              Jun 13 '17 at 20:04














            • 2




              Can you explain how/why you believe this answers the question?
              – Scott
              Jun 13 '17 at 20:04








            2




            2




            Can you explain how/why you believe this answers the question?
            – Scott
            Jun 13 '17 at 20:04




            Can you explain how/why you believe this answers the question?
            – Scott
            Jun 13 '17 at 20:04


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f22218%2flinux-ls-to-show-only-filename-date-and-size%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre