Show the year while listing files in the current directory

Clash Royale CLAN TAG#URR8PPP
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
add a comment |
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
no i dont think i try "ls -lT" its not found
– WAEL
Oct 10 '12 at 7:12
ls -lTis 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,lsgenerally doesn’t have a way to display it. So, in general, this is impossible.
– G-Man
Apr 22 at 2:46
add a comment |
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
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
linux shell-script date
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 -lTis 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,lsgenerally doesn’t have a way to display it. So, in general, this is impossible.
– G-Man
Apr 22 at 2:46
add a comment |
no i dont think i try "ls -lT" its not found
– WAEL
Oct 10 '12 at 7:12
ls -lTis 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,lsgenerally 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
add a comment |
5 Answers
5
active
oldest
votes
You can use man ls and here you can find --time-style parameter. Or you can use:
ls --full-time.
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 stylels -l --time-style=+%F
– sobi3ch
Sep 19 '17 at 6:56
add a comment |
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.
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 oflsto date changed rather than the default date modified.
– Mateen Ulhaq
Apr 22 at 1:41
1
ls -ldisplays 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, sols -laccan display times (instead of years) just as much asls -lacan. Besides, as Mateen Ulhaq points out,ls -lacdoes not display the same dates thatls -ladoes. 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
add a comment |
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. :)
Orls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--fwouldn't work as there's also a --file-type and --format). Note that a future version may introduce a--full-permsso 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
add a comment |
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)
add a comment |
If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
You can use man ls and here you can find --time-style parameter. Or you can use:
ls --full-time.
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 stylels -l --time-style=+%F
– sobi3ch
Sep 19 '17 at 6:56
add a comment |
You can use man ls and here you can find --time-style parameter. Or you can use:
ls --full-time.
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 stylels -l --time-style=+%F
– sobi3ch
Sep 19 '17 at 6:56
add a comment |
You can use man ls and here you can find --time-style parameter. Or you can use:
ls --full-time.
You can use man ls and here you can find --time-style parameter. Or you can use:
ls --full-time.
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 stylels -l --time-style=+%F
– sobi3ch
Sep 19 '17 at 6:56
add a comment |
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 stylels -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
add a comment |
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.
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 oflsto date changed rather than the default date modified.
– Mateen Ulhaq
Apr 22 at 1:41
1
ls -ldisplays 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, sols -laccan display times (instead of years) just as much asls -lacan. Besides, as Mateen Ulhaq points out,ls -lacdoes not display the same dates thatls -ladoes. 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
add a comment |
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.
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 oflsto date changed rather than the default date modified.
– Mateen Ulhaq
Apr 22 at 1:41
1
ls -ldisplays 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, sols -laccan display times (instead of years) just as much asls -lacan. Besides, as Mateen Ulhaq points out,ls -lacdoes not display the same dates thatls -ladoes. 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
add a comment |
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.
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.
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 oflsto date changed rather than the default date modified.
– Mateen Ulhaq
Apr 22 at 1:41
1
ls -ldisplays 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, sols -laccan display times (instead of years) just as much asls -lacan. Besides, as Mateen Ulhaq points out,ls -lacdoes not display the same dates thatls -ladoes. 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
add a comment |
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 oflsto date changed rather than the default date modified.
– Mateen Ulhaq
Apr 22 at 1:41
1
ls -ldisplays 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, sols -laccan display times (instead of years) just as much asls -lacan. Besides, as Mateen Ulhaq points out,ls -lacdoes not display the same dates thatls -ladoes. 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
add a comment |
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. :)
Orls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--fwouldn't work as there's also a --file-type and --format). Note that a future version may introduce a--full-permsso 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
add a comment |
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. :)
Orls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--fwouldn't work as there's also a --file-type and --format). Note that a future version may introduce a--full-permsso 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
add a comment |
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. :)
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. :)
edited May 24 at 21:24
answered May 24 at 14:36
G_Style
314
314
Orls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--fwouldn't work as there's also a --file-type and --format). Note that a future version may introduce a--full-permsso 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
add a comment |
Orls --fu. GNU-style long options can be abbreviated as long as there's no ambiguity (--fwouldn't work as there's also a --file-type and --format). Note that a future version may introduce a--full-permsso 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
add a comment |
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)
add a comment |
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)
add a comment |
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)
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)
answered Jan 6 at 21:19
Daniel Cambría
211
211
add a comment |
add a comment |
If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e
add a comment |
If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e
add a comment |
If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e
If you're using busybox (embedded distros, e.g. OpenWRT, LEDE), the switch you're looking for is -e
answered Dec 14 at 18:54
Code Bling
1012
1012
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
no i dont think i try "ls -lT" its not found
– WAEL
Oct 10 '12 at 7:12
ls -lTis 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,
lsgenerally doesn’t have a way to display it. So, in general, this is impossible.– G-Man
Apr 22 at 2:46