List Doughnut Contents with the ls Command

List Doughnut Contents with the ls Command

Trouble is afoot in “the_doughnuts” directory. It seems our friend Homer Price has built himself a newfangled, automatic, doughnut-making machine, and he can’t get it to shut off! On top of that, Ada Lovelace lost her diamond bracelet in the batter, and Homer is certain that it’s encased in one of his circular snack cakes. This looks like a job for ls, or list doughnut contents… I mean list directory contents.

Lets cd to “the_doughnuts” directory, and assess the situation. Using “ls” without specifying a path will list the contents of the current working directory.


How convenient, Homer has categorized all of his doughnuts into separate directories. We could list the contents of each directory individually, or we could use a wildcard to list the contents of all of the subdirectories.

ls subdirectories

What a delicious display of doughnuts! My gut tells me that the bracelet is most likely hidden inside one of those filled doughnuts. Lets recursively list all of the contents of the filled directory.

ls recursively

That certainly looks tasty, but we’re no closer to finding the bracelet. This calls for a snack break, but Homer’s lousy shop doesn’t even carry my favorite kind of doughnuts. I find it hard to believe that he would sell cake doughnut holes but not cake doughnuts. Say, I wonder if somebody else had their eye on the cake doughnuts. Maybe they hid them! Lets list the contents of “the_dougnuts” directory again, but this time we’ll use the “-a” option to show any hidden files.

list all directory contents

Aha! Just as I suspected. Lets take a look inside the secret “.cake” directory.

recursively list directory contents

Would you look at that, there’s a bracelet inside of the traditional cake doughnut! We have to be sure that it belongs to Ms. Lovelace, so lets use the “-l” option to format the shell output in a long list.

ls long list

Using the “-l” option shows us the file’s permissions, ownership, size, and date last modified in addition to the name. Sure enough, that bracelet belongs to Ada. My goodness, that thing is big. I’m not good with computing file sizes, so lets add the “-h” option to display the file size in a human-readable format.

ls long list human readable

Whoa, one point three gigabytes! We may have solved the mystery of the missing jewelry, but I’ll never understand how that bracelet fit inside of one doughnut.

Featured image credit: Jonathan McIntosh

List Doughnut Contents with the ls Command was posted by on . JR is one of the three humans that run the behind-the-scene affairs of The Hello World Program. He is interested in spreading the good robot word over the vast Inter-webs. His contributions to the show include editing, web programming, design, and music composition.

Discuss this article in the Comments below, or and it with your friends. Learn more about Linux by subscribing to The Hello World Newsletter .

Join the Discussion

Subscribe to our Mailing List

Stay up to date on the latest videos and tutorials with our monthly newsletter

The email entered is invalid