Show the year while listing files in the current directory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












43














I am working on a Red Hat server. The commands ls -l or ll giving me the date and time in format +"%b %-d %H:%M".



I want to list the files in a way where the year when each was file created would appear within the date.



How is that possible?










share|improve this question























  • no i dont think i try "ls -lT" its not found
    – WAEL
    Oct 10 '12 at 7:12










  • ls -lT is for mac osx
    – Kris Roofe
    Jun 7 '17 at 8:38






  • 1




    In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
    – G-Man
    Apr 22 at 2:46















43














I am working on a Red Hat server. The commands ls -l or ll giving me the date and time in format +"%b %-d %H:%M".



I want to list the files in a way where the year when each was file created would appear within the date.



How is that possible?










share|improve this question























  • no i dont think i try "ls -lT" its not found
    – WAEL
    Oct 10 '12 at 7:12










  • ls -lT is for mac osx
    – Kris Roofe
    Jun 7 '17 at 8:38






  • 1




    In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
    – G-Man
    Apr 22 at 2:46













43












43








43


8





I am working on a Red Hat server. The commands ls -l or ll giving me the date and time in format +"%b %-d %H:%M".



I want to list the files in a way where the year when each was file created would appear within the date.



How is that possible?










share|improve this question















I am working on a Red Hat server. The commands ls -l or ll giving me the date and time in format +"%b %-d %H:%M".



I want to list the files in a way where the year when each was file created would appear within the date.



How is that possible?







linux shell-script date






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 27 at 17:09









U880D

399414




399414










asked Oct 10 '12 at 7:05









WAEL

5142615




5142615











  • no i dont think i try "ls -lT" its not found
    – WAEL
    Oct 10 '12 at 7:12










  • ls -lT is for mac osx
    – Kris Roofe
    Jun 7 '17 at 8:38






  • 1




    In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
    – G-Man
    Apr 22 at 2:46
















  • no i dont think i try "ls -lT" its not found
    – WAEL
    Oct 10 '12 at 7:12










  • ls -lT is for mac osx
    – Kris Roofe
    Jun 7 '17 at 8:38






  • 1




    In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
    – G-Man
    Apr 22 at 2:46















no i dont think i try "ls -lT" its not found
– WAEL
Oct 10 '12 at 7:12




no i dont think i try "ls -lT" its not found
– WAEL
Oct 10 '12 at 7:12












ls -lT is for mac osx
– Kris Roofe
Jun 7 '17 at 8:38




ls -lT is for mac osx
– Kris Roofe
Jun 7 '17 at 8:38




1




1




In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
– G-Man
Apr 22 at 2:46




In general, Unix doesn’t keep track of the creation times of files, and, even when it does, ls generally doesn’t have a way to display it. So, in general, this is impossible.
– G-Man
Apr 22 at 2:46










5 Answers
5






active

oldest

votes


















63














You can use man ls and here you can find --time-style parameter. Or you can use:



ls --full-time.






share|improve this answer
















  • 1




    @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
    – The Dark Knight
    Oct 10 '12 at 9:33






  • 1




    Example for time style ls -l --time-style=+%F
    – sobi3ch
    Sep 19 '17 at 6:56


















6














Since you asked for the year, ls -lac is an easy one to remember if, like me, you use ls -la all the time. The c gives you ctime which will display a year if it's not the current year or the hour and minute if it is.






share|improve this answer




















  • I like this. A lot less noise in the output and only one letter to remember in the future.
    – Eric
    May 8 '17 at 17:18










  • This seems to change the behavior of ls to date changed rather than the default date modified.
    – Mateen Ulhaq
    Apr 22 at 1:41







  • 1




    ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
    – G-Man
    Apr 22 at 2:46






  • 2




    How in the world did this “answer” get seven votes?
    – G-Man
    Apr 22 at 2:46


















3














In addition to Jan Marek's answer.... I've noticed you can get away with just:




ls --full or ls --fu




which will do the same thing as ls --full-time as he described. Thanks Stéphane Chazelas. Now I type ls --fu everywhere. :)






share|improve this answer






















  • Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
    – Stéphane Chazelas
    May 24 at 15:19











  • Great to know! Its all about typing less. :)
    – G_Style
    May 24 at 21:23


















2














ls -l will display month day and year - since, according to BSD man page:
If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.



So, to make sure that year will always be shown, use:



ls --time-style=long-iso (GNU/Linux)



ls -lT will display display complete time information in BSD (MacOS)






share|improve this answer




























    0














    If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e






    share|improve this answer




















      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%2f50431%2fshow-the-year-while-listing-files-in-the-current-directory%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      5 Answers
      5






      active

      oldest

      votes








      5 Answers
      5






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      63














      You can use man ls and here you can find --time-style parameter. Or you can use:



      ls --full-time.






      share|improve this answer
















      • 1




        @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
        – The Dark Knight
        Oct 10 '12 at 9:33






      • 1




        Example for time style ls -l --time-style=+%F
        – sobi3ch
        Sep 19 '17 at 6:56















      63














      You can use man ls and here you can find --time-style parameter. Or you can use:



      ls --full-time.






      share|improve this answer
















      • 1




        @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
        – The Dark Knight
        Oct 10 '12 at 9:33






      • 1




        Example for time style ls -l --time-style=+%F
        – sobi3ch
        Sep 19 '17 at 6:56













      63












      63








      63






      You can use man ls and here you can find --time-style parameter. Or you can use:



      ls --full-time.






      share|improve this answer












      You can use man ls and here you can find --time-style parameter. Or you can use:



      ls --full-time.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Oct 10 '12 at 7:13









      Jan Marek

      2,362910




      2,362910







      • 1




        @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
        – The Dark Knight
        Oct 10 '12 at 9:33






      • 1




        Example for time style ls -l --time-style=+%F
        – sobi3ch
        Sep 19 '17 at 6:56












      • 1




        @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
        – The Dark Knight
        Oct 10 '12 at 9:33






      • 1




        Example for time style ls -l --time-style=+%F
        – sobi3ch
        Sep 19 '17 at 6:56







      1




      1




      @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
      – The Dark Knight
      Oct 10 '12 at 9:33




      @bob: Completely agree with Turco. If you don't do that, nobody is going to bother about answering your question .
      – The Dark Knight
      Oct 10 '12 at 9:33




      1




      1




      Example for time style ls -l --time-style=+%F
      – sobi3ch
      Sep 19 '17 at 6:56




      Example for time style ls -l --time-style=+%F
      – sobi3ch
      Sep 19 '17 at 6:56













      6














      Since you asked for the year, ls -lac is an easy one to remember if, like me, you use ls -la all the time. The c gives you ctime which will display a year if it's not the current year or the hour and minute if it is.






      share|improve this answer




















      • I like this. A lot less noise in the output and only one letter to remember in the future.
        – Eric
        May 8 '17 at 17:18










      • This seems to change the behavior of ls to date changed rather than the default date modified.
        – Mateen Ulhaq
        Apr 22 at 1:41







      • 1




        ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
        – G-Man
        Apr 22 at 2:46






      • 2




        How in the world did this “answer” get seven votes?
        – G-Man
        Apr 22 at 2:46















      6














      Since you asked for the year, ls -lac is an easy one to remember if, like me, you use ls -la all the time. The c gives you ctime which will display a year if it's not the current year or the hour and minute if it is.






      share|improve this answer




















      • I like this. A lot less noise in the output and only one letter to remember in the future.
        – Eric
        May 8 '17 at 17:18










      • This seems to change the behavior of ls to date changed rather than the default date modified.
        – Mateen Ulhaq
        Apr 22 at 1:41







      • 1




        ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
        – G-Man
        Apr 22 at 2:46






      • 2




        How in the world did this “answer” get seven votes?
        – G-Man
        Apr 22 at 2:46













      6












      6








      6






      Since you asked for the year, ls -lac is an easy one to remember if, like me, you use ls -la all the time. The c gives you ctime which will display a year if it's not the current year or the hour and minute if it is.






      share|improve this answer












      Since you asked for the year, ls -lac is an easy one to remember if, like me, you use ls -la all the time. The c gives you ctime which will display a year if it's not the current year or the hour and minute if it is.







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Jul 28 '15 at 17:47









      PhilT

      17713




      17713











      • I like this. A lot less noise in the output and only one letter to remember in the future.
        – Eric
        May 8 '17 at 17:18










      • This seems to change the behavior of ls to date changed rather than the default date modified.
        – Mateen Ulhaq
        Apr 22 at 1:41







      • 1




        ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
        – G-Man
        Apr 22 at 2:46






      • 2




        How in the world did this “answer” get seven votes?
        – G-Man
        Apr 22 at 2:46
















      • I like this. A lot less noise in the output and only one letter to remember in the future.
        – Eric
        May 8 '17 at 17:18










      • This seems to change the behavior of ls to date changed rather than the default date modified.
        – Mateen Ulhaq
        Apr 22 at 1:41







      • 1




        ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
        – G-Man
        Apr 22 at 2:46






      • 2




        How in the world did this “answer” get seven votes?
        – G-Man
        Apr 22 at 2:46















      I like this. A lot less noise in the output and only one letter to remember in the future.
      – Eric
      May 8 '17 at 17:18




      I like this. A lot less noise in the output and only one letter to remember in the future.
      – Eric
      May 8 '17 at 17:18












      This seems to change the behavior of ls to date changed rather than the default date modified.
      – Mateen Ulhaq
      Apr 22 at 1:41





      This seems to change the behavior of ls to date changed rather than the default date modified.
      – Mateen Ulhaq
      Apr 22 at 1:41





      1




      1




      ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
      – G-Man
      Apr 22 at 2:46




      ls -l displays date and time for dates that are in the past six months, and date and year for other dates.  ctime can be in the past six months just as much as mtime (modification date) can, so ls -lac can display times (instead of years) just as much as ls -la can.  Besides, as Mateen Ulhaq points out, ls -lac does not display the same dates that ls -la does. This answer is wrong.
      – G-Man
      Apr 22 at 2:46




      2




      2




      How in the world did this “answer” get seven votes?
      – G-Man
      Apr 22 at 2:46




      How in the world did this “answer” get seven votes?
      – G-Man
      Apr 22 at 2:46











      3














      In addition to Jan Marek's answer.... I've noticed you can get away with just:




      ls --full or ls --fu




      which will do the same thing as ls --full-time as he described. Thanks Stéphane Chazelas. Now I type ls --fu everywhere. :)






      share|improve this answer






















      • Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
        – Stéphane Chazelas
        May 24 at 15:19











      • Great to know! Its all about typing less. :)
        – G_Style
        May 24 at 21:23















      3














      In addition to Jan Marek's answer.... I've noticed you can get away with just:




      ls --full or ls --fu




      which will do the same thing as ls --full-time as he described. Thanks Stéphane Chazelas. Now I type ls --fu everywhere. :)






      share|improve this answer






















      • Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
        – Stéphane Chazelas
        May 24 at 15:19











      • Great to know! Its all about typing less. :)
        – G_Style
        May 24 at 21:23













      3












      3








      3






      In addition to Jan Marek's answer.... I've noticed you can get away with just:




      ls --full or ls --fu




      which will do the same thing as ls --full-time as he described. Thanks Stéphane Chazelas. Now I type ls --fu everywhere. :)






      share|improve this answer














      In addition to Jan Marek's answer.... I've noticed you can get away with just:




      ls --full or ls --fu




      which will do the same thing as ls --full-time as he described. Thanks Stéphane Chazelas. Now I type ls --fu everywhere. :)







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited May 24 at 21:24

























      answered May 24 at 14:36









      G_Style

      314




      314











      • Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
        – Stéphane Chazelas
        May 24 at 15:19











      • Great to know! Its all about typing less. :)
        – G_Style
        May 24 at 21:23
















      • Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
        – Stéphane Chazelas
        May 24 at 15:19











      • Great to know! Its all about typing less. :)
        – G_Style
        May 24 at 21:23















      Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
      – Stéphane Chazelas
      May 24 at 15:19





      Or ls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--f wouldn't work as there's also a --file-type and --format). Note that a future version may introduce a --full-perms so it's dangerous to rely on that.
      – Stéphane Chazelas
      May 24 at 15:19













      Great to know! Its all about typing less. :)
      – G_Style
      May 24 at 21:23




      Great to know! Its all about typing less. :)
      – G_Style
      May 24 at 21:23











      2














      ls -l will display month day and year - since, according to BSD man page:
      If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.



      So, to make sure that year will always be shown, use:



      ls --time-style=long-iso (GNU/Linux)



      ls -lT will display display complete time information in BSD (MacOS)






      share|improve this answer

























        2














        ls -l will display month day and year - since, according to BSD man page:
        If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.



        So, to make sure that year will always be shown, use:



        ls --time-style=long-iso (GNU/Linux)



        ls -lT will display display complete time information in BSD (MacOS)






        share|improve this answer























          2












          2








          2






          ls -l will display month day and year - since, according to BSD man page:
          If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.



          So, to make sure that year will always be shown, use:



          ls --time-style=long-iso (GNU/Linux)



          ls -lT will display display complete time information in BSD (MacOS)






          share|improve this answer












          ls -l will display month day and year - since, according to BSD man page:
          If the modification time of the file is more than 6 months in the past or future, then the year of the last modification is displayed in place of the hour and minute fields.



          So, to make sure that year will always be shown, use:



          ls --time-style=long-iso (GNU/Linux)



          ls -lT will display display complete time information in BSD (MacOS)







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 6 at 21:19









          Daniel Cambría

          211




          211





















              0














              If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e






              share|improve this answer

























                0














                If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e






                share|improve this answer























                  0












                  0








                  0






                  If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e






                  share|improve this answer












                  If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 14 at 18:54









                  Code Bling

                  1012




                  1012



























                      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%2f50431%2fshow-the-year-while-listing-files-in-the-current-directory%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

                      Peggy Mitchell

                      Palaiologos

                      The Forum (Inglewood, California)