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.
ls
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 */
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 -R filled
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.
ls -a
Aha! Just as I suspected. Lets take a look inside the secret “.cake” directory.
ls -R .cake
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 -l .cake/traditional
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 -lh .cake/traditional
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