3

This is my question: How to sort files by file extensions through the command line?

Jorge Castro
  • 73,907
Ederico
  • 6,447

1 Answers1

7

This is what you are looking for:

ls -Xl

From the man file:

 -X                         sort alphabetically by entry extension

This is an example of how you could move .txt files into a test forlder:

mv *.txt test/
bioShark
  • 4,335
  • Thanks, that is useful. Yet, it is not exactly what I wanted. I guess my question isn't that clear now that I read it again. What I would want is to move files from one folder into a specific folder by using the file extension. Turns out I managed by using the mv command. – Ederico Nov 19 '11 at 15:26
  • 1
    I've added a mv command to move files based on extension. Cheers – bioShark Nov 19 '11 at 19:18