Skip to content

Sort the list of file names using ls command

To list only the file names using ls command we can pass -a option to it.

anand@hpfolio:/Minposts/Music$ ls -a
 .                                         Get_up_hustle_repeat.mp4           'Instant Crush - Corbyn Kites.mp3'  'Orient - SefChol.mp3'
 ..                                       'Grass - Silent Partner.mp3'        'Jay Sweeps - Geographer.mp3'       'Subharmonic Bliss - Loopop.mp3'
'Deliberate Thought - Kevin MacLeod.mp3'  'Hello 6am - Mylar Melodies.mp3'    'Koto San - Ofshane.mp3'            'This is Not a Dolphin - True Cuckoo.mp3'
'Float - Emily A. Sprague.mp3'            'Icelandic Arpeggios - DivKid.mp3'  'minposts_playlists (1).png'        'Wind Riders - Asher Fulero.mp3'

You can sort the file names by passing | sort to the ls -a command

anand@hpfolio:/Minposts/Music$ ls -a | sort
.
..
Deliberate Thought - Kevin MacLeod.mp3
Float - Emily A. Sprague.mp3
Get_up_hustle_repeat.mp4
Grass - Silent Partner.mp3
Hello 6am - Mylar Melodies.mp3
Icelandic Arpeggios - DivKid.mp3
Instant Crush - Corbyn Kites.mp3
Jay Sweeps - Geographer.mp3
Koto San - Ofshane.mp3
minposts_playlists (1).png
Orient - SefChol.mp3
Subharmonic Bliss - Loopop.mp3
This is Not a Dolphin - True Cuckoo.mp3
Wind Riders - Asher Fulero.mp3

You can remove -a option if you don’t want hidden files to be included.

See also  Expose your local application as a public URL using ngrok

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.