Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I need to find my recently used files, this command:

ls -lt

lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because wont fit in terminal screen.

After finding out that tac inverses the output, I use: ls -lt dir/ | tac Is there more fun way of doing it, without using external scripts/utils?

share|improve this question

The -r does the same thing for ls as tac does for any command which needs reverse file ordering.

So you could just write

ls -ltr

From man page:

  • -l List in long format. If the output is to a terminal, a total sum for all the file sizes is output on a line before the long listing.
  • -r Reverse the order of the sort to get reverse lexicographical order or the oldest entries first (or largest files last, if combined with sort by size.
  • -t Sort by time modified (most recently modified first) before sorting the operands by lexicographical order.
share|improve this answer
1  
Thanks! Used ls for ages and never new there's -r :p – linux-newbie Nov 7 '12 at 18:46
3  
This is remembered with the handy mnemonic "later". As in, "I want to see the files that were changed later: ls -ltr" – bahamat Nov 7 '12 at 20:16
1  
Its also sad because in most other popular commands it stands for 'recursive'... – dolzenko Sep 10 '14 at 20:59
    
I feel a bit silly for not noticing that after looking at the man page for ls considering that the modifiers are listed in alphabetical order. In related news, there is still a recursive option for ls, but it is -R instead of -r. – Jonathan Thiele Apr 23 '15 at 17:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.