10/5/2023 0 Comments Sort dcommand in linux![]() Here's that command, followed by its output for the same directory shown in the previous command: rwx- 1 al al 25232591 apache-cxf-2.1.2.zipĪlternatively, to sort by filesize from smallest to largest, again just add the -r option to reverse the default sort, as shown in this ls command example: Here's some sample output from that command: (Note that those last two characters are a lowercase letter 'L' and and uppercase letter 'S'.) All you have to do is use the -S argument (that's an uppercase letter 'S') to your Unix or Linux ls command, like this: What I just learned is that you can sort the ls command output by file size without piping the ls output into the Linux sort command. To do the opposite, and sort the ls output by modification time from oldest to newest, just add the -r argument to the ls command, like this: In this ls command, the -t argument to the ls command gives us the sorting by file modification time, and the -l argument gives us this long/wide output. This results in output similar to the following:ĭrwx-+ 46 al al 1564 Oct 22 11:48 Desktopĭrwx-+ 25 al al 850 Oct 18 17:49 Downloadsĭrwx-+ 224 al al 7616 Oct 15 20:13 Picturesĭrwxr-xr-x 31 al al 1054 Oct 15 17:09 tmpĭrwxr-xr-x 19 al al 646 Jul 20 19:29 Workĭrwxr-xr-x+ 23 al al 782 Jun 20 11:43 Sitesĭrwxr-xr-x 9 al al 306 May 20 19:52 AlexanderConsultingĭrwxr-xr-x 5 al al 170 GarageBandProjectsĭrwxr-xr-x 3 al al 102 DefaultEclipseWorkspaceĭrwxr-xr-x 3 al al 102 1 al al 7608 MYSQL_README To help us get rolling, here are two quick examples that show how to sort ls command output by file modification time.įirst, to sort the ls command output by file modification time, in order from the most recently-modified file (newest) to the oldest, use this ls command: Sort Linux ls output by file modification time In this short tutorial I'll demonstrate the Unix/Linux ls command file sorting options I just learned. Off the top of my head I knew how to sort the ls output by file modification time, and also knew how to sort ls with the Linux sort command, but I didn't realize there were other cool file sorting options available until I looked them up. A couple of days ago I was asked how to sort the output from the Unix and Linux ls command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |