Walker News

How To Use ls Command To Sort File Listing By Time In Linux?

A simple tip of using the Linux ls command option switch to display file listing ordered by time!

Although the GUI file explorer is simpler and intuitive than the cold black and white text console, Linux command line tools are powerful and convenient for shell scripting.

In brief, these are three ls command option switches used to sort files by time in three different contexts:
  • -lt to sort by time of file created or time of file content changed.
     
  • -lct to sort by time of file status information changed, e.g. file permission changed by chmod command.
     
  • -lut to sort by time of file access, e.g. open file for view via less, cat, more, pg, vi, etc.

How to use Linux ls command to sort file listing according to time of file created, changed, or accessed?

By default, the Linux file listing command displays files in the order of newer to older. If you would like to reverse it, include the -r option switch too, e.g. ls -ltr to display files sorted by time of file created/changed, from older to newer.

Custom Search

2014  •  Privacy Policy