


But if you have 20 or 50 or 100 files in the current directory and you want to see which files were accessed or modified recently, this will be a pain. Now, this is good enough if you have a few files. For older files, it shows the year (notice 2021?). Linux shows the time for the files created in the current year. The newest files are displayed at the top. I am going to sort ls command output by size in long listing with ls -lt: :~/Apps$ ls -ltĭo you notice the change? Now the entries are sorted by time. rwxr-xr-x 1 abhishek abhishek 57430439 Mar 17 07:52 pcloudĭrwxr-xr-x 2 abhishek abhishek 4096 PenguinSubtitlePlayer-Linux rwxr-xr-x 1 abhishek abhishek 89697412 balenaEtcher-1.5.116-圆4.AppImageĭrwxr-xr-x 6 abhishek abhishek 4096 cpufetch Now, if I use ls -l, it will display one entry per line, still sorted in alphabetical order. Obsidian-0.13.19.AppImage ScreenCloud-v1.5.3-x86_64.AppImageīy default, it just gives the name of the files and directories in alphabetical order. Let me show you the contents of my sample directory: :~/Apps$ ls Let's go a little further and understand it with practical examples. You'll get the same result for ls -lrt and ls -ltr. The order of the options doesn't matter here. The newest files are shown at the bottom. So when you combine them all, you display the contents in the present directory sorted in reverse chronological order. r: This one reverses the order of ls command output.t: This one sorts the long listing output based on time.It shows one file in each line with additional info such as permissions, ownership, size, timestamps etc.

l: This is for the long listing of the contents.The lrt part is a combination of three different options: The ls command is used for listing the contents of a directory. I won't judge you because I have been there myself. If you are looking for an explanation, you are either a new Linux user or don't use Linux commands quite often. The -lrt provides additional options to the command.
#LINUX LS DETAILS SOFTWARE#
In theory one could use watch for this, but I wanted to see a file as soon as it appeared/disappeared.As a software developer or tester, you'll often use the "ls -lrt" command, specially while dealing with a large number of files.Īctually, it's just ls command. However it was printing it all on differnet lines, which was making the uniq useless, and increasing the amount of noise. The uniq prevents it from spamming my terminal and only showing changes. I had constructed this simple command line: while ] do ls done | uniq The reason I want to do this is that I want to monitor the files in a directory that were changing quickly. $ lsįile1 file10 file11 file12 file13 file14 file15 file16 file17 file18 file19 file2 file3 file4 file5 file6 file7 file8 file9įile1 file11 file13 file15 file17 file19 file3 file5 file7 file9įile10 file12 file14 file16 file18 file2 file4 file6 file8 There's a -C argument that sorta does that, but it will split it into several lines. Is there some way to make ls print out on one line as if it's to a terminal when it's not. Ls prints differently depending on whether the output is to a terminal or to something else.
