![]() ![]() So they are grouped together but displayed in alphabetical order with export.json before redirects.json. rw-rw-r- 1 abhishek abhishek 106 Oct 20 11:55 redirects.jsonĪs you can see, the hard_link file was the most recent and hence displayed at the top.īut both redirects.json and export.json have the same mtime. rw-rw-r- 1 abhishek abhishek 311 Oct 20 11:58 hard_link Now let me sort the ls output based on time: :~/test$ ls -lt I'll also change the modified time of another file to show the grouping of files properly. You can use the stat command to verify it. The two files will have the same modified time now. Let me use the touch command to change the modify time of two files. rw-rw-r- 1 abhishek abhishek 311 Sep 22 12:19 hard_link rw-rw-r- 1 abhishek abhishek 106 Oct 20 11:54 redirects.json ![]() The files with exact same modified time will be sorted alphabetically but they will be grouped together. What if two files have the same modified time? I hope you are familiar with the file timestamps in Linux. Also, the time here is modified time (or mtime) by default. See how the output of the ls command changes based on date and time.Īs you can see, the ls output is modified by time, not just date. ls -tĬombining it with the long listing option -l shows the timestamp as well. To sort the contents of a directory by time, use the -t option of the ls command. I'll show you all this in detail in this article. You'll notice that if you have multiple files that were modified the same day but at different times. rw-rw-r- 1 abhishek abhishek 4794657 Sep 27 20:36 export.jsonĪs you can see in the above output, the content is sorted by date, not names.Īctually, these are sorted by time, not date. rw-rw-r- 1 abhishek abhishek 106 Sep 27 20:39 redirects.json rw-r-r- 1 abhishek abhishek 12817 Oct 20 09:56 sample.txtĭrwxrwxr-x 2 abhishek abhishek 4096 Oct 17 12:33 my_dir This way, the ls command lists the files that were recently modified first. If you want to sort the output by the modified time, you can use the option -t: ls -lt By default, the ls command shows the result in alphabetical order. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |