Super User is a question and answer site for computer enthusiasts and power users. 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

Example list sorted from left to right.

DATA2
DATA4
FILE1
FILE3

Example list sorted from right to left.

FILE1
DATA2
FILE3
DATA4

How do I do this?

share|improve this question
up vote 8 down vote accepted
cat file | rev | sort | rev

Where file contains the content needing to be sorted.

$ cat file

DATA2
DATA4
FILE1
FILE3

Output:

$ cat file | rev | sort | rev

FILE1
DATA2
FILE3
DATA4

All it does is reverse each line before applying sort, then reverses each line back again.

share|improve this answer
1  
I see your title says "ls", if so, just replace cat file with ls – Paul Nov 24 '11 at 5:35
    
+1 Did not know about rev. I have used bash on and off since 1992 and I still learn about new commands regularly. – Nifle Nov 24 '11 at 8:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .