-3

So I was trying to do some research on it, but I could not find the answer. So I know that ls -l returns all things in the folder alphabetically, whilst ls -alt returns a list of files by their modification date, though without respect to alphabetical ordering.

I tried doing ls -l -alt, and also ls -alt -l, still no luck. What is the correct way to group them together?

Edit: With example.

Say I have the following list of directories:

aalexand  bam       carson    duong     garrett   hollande  jjackson  ksmith    mkumba    olandt    rcs       solorzan  truong    yoo
aalfs     battiste  chae      echo      ghamilto  holly     jkelly    kturner   mls       old.2016  reichman  sophia    twong     zbib

I want to order them by alphabet, so say aalexand comes first. However, if aalfs has been modified last. So in other words has been changed more recently (not really sure how to structure this with proper grammar) it should appear first.

So if this were like a SQL query then we order by date last modified, group by directory name.

SomeStudent
  • 2,856
  • 1
  • 22
  • 36
  • @DaniSpringer it is funny u said that because that is what I just added in my edit, lol – SomeStudent Feb 19 '17 at 01:01
  • http://stackoverflow.com/questions/380817/best-way-to-simulate-group-by-from-bash –  Feb 19 '17 at 01:03
  • Your description makes no sense. You can't have two directories with the same name, so grouping by name does nothing. – melpomene Feb 19 '17 at 01:13

1 Answers1

1

I am not sure what you want to do.

But, first of all: ls -l -alt is a double use of the -l parameter (take a look at man ls for more information about the parameters).

ls -l (l stands for list) just lists only one file per line (if you don't need the extra information like permissions, use -1 instead of -l). The -a includes hidden files. -t is for sorting by modified time. You cannot sort by name AND by time, except if two files would have the same name, which is not posible. Could you please explain your wish further?

Maybe you include a short example list of files including their modified time and your desired output, maybe then I can understand.

mfnalex
  • 833
  • 5
  • 16