Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash ls; output a time of modification of files including year and seconds [closed]

Tags:

linux

bash

ls

I want to output a time of modification of files including year and seconds. I tried to use ls -linT, means -T must do it, but it doesn't. -T is recognized as tabulation size. I'm searching a solution using ls. Could someone help me, please?

like image 490
Andrey Baulin Avatar asked Dec 22 '12 01:12

Andrey Baulin


People also ask

How do you do ls by time?

To sort by time in Linux ls command, we can use the -lt option. These two options will cause ls to sort files by modified time, with the most recently modified files appearing first and output is in long format. -t Sort by descending time modified (most recently modified first).

Which of the ls command will sort the formatted listing by time of modification?

ls -s: list the files along with their size. ls -t: sort the list by time of modification, with the newest at the top. ls -S: sort the list by size, with the largest at the top. ls -r: reverse the sorting order.

What is modification time in Linux?

Modified Time. The modified timestamp contains the time the file's data has been changed. It means when we make changes to the actual contents of the file, the file system will update the modification time.

How do you check when was file last accessed Linux?

To see the access time for a file with ls , append the -u option in your command. In this case, our access time is the same as the file's modified time, which is normal for files that have not been accessed since they were last saved.


1 Answers

Try --time-style=full-iso, or just --full-time:

ls -l --time-style=full-iso
ls --full-time

From man-page:

--time-style=STYLE with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like date'; if FORMAT is FORMAT1<newline>FORMAT2, FORMAT1 applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed withposix-', STYLE takes effect only outside the POSIX locale

So you can also have a format specifier (see date man-page for format string):

ls -l --time-style=+"%Y %H:%M:%S"
like image 125
perreal Avatar answered Oct 01 '22 11:10

perreal