Some Fun With Formatting The Output From ‘ls’

Today’s article will be a nice and simple one, in which we’ll have some fun with formatting the output from ‘ls’. It’s just a quick article today, as there’s no real reason to make this all that difficult. Read on, my dear readers!

While it’s true that you shouldn’t parse the output from the ‘ls’ command, you can format it to get an output that more suits your needs. You might want to do this to more easily understand the output from ‘ls’. There are a half dozen or so formatting options and we’ll show them all to you in this article. One (or more) of them might tickle your fancy.

Obviously, we’ll be using the ‘ls’ command. The ‘ls’ command describes itself like this:

ls – list directory contents

Which is exactly what it does. It’s not a very complicated command, as far as some commands go, but there are a lot of options. Like always, I highly suggest that you read the man page (man ls) to get more information than will be contained in this article.

Anyhow, I said this will be a short article, so I will just get right into the meat of the article instead of typing a bunch of additional fluff. You’re welcome!

Formatting The Output From ‘ls’:

This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, you can choose to view the output of ‘ls’ with a variety of formats. They’re more or less self-explanatory, so I’m just going to show them all to you. If you’re confused by any of them, try them in your terminal, which will should make it more clear.

I even made you an alphabetized list! See? I am helpful today!

So, for ls --format=across you’ll get the output spread across your screen (as much as possible). If you use ls --format=comma, the files will be separated by a comma.

Out of all of them, I tend to use ls --format=verbose more often than I use any of the other ways of formatting the output from ‘ls’. It gives me just enough information, from file modification date and time to the file’s permissions. So, out of all of them, that’s the one I’ll use most often. 

Feel free to flip through and try them all. You’re bound to find something interesting in there. The ‘ls’ command is surprisingly useful, and it’s harmless enough for you to explore it at length.

Closure:

See? I told you that it’d be a pretty short article today. I just showed you some ways of formatting the output from ‘ls’ and that’s all I’ve done. There’s no reason to make this longer than necessary. I think my readers are smart enough to take it from here, and figure out what they like most, or find the most useful.

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

Subscribe To Our Newsletter
Get notified when new articles are published! It's free and I won't send you any spam.
Linux Tips
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.