Video Coming Soon...
50: stat Then du
WARNING: This is from the Go course but I'm rewriting the code and the description to fit C. If you want to attempt it go ahead. The challenge is the same, just no examples yet.
You've had 7 exercises of easy commands, so now you're going to do two related more complex commands. The first one is stat, which gives you information on a file. The second is du which gives you "disk usage" information, or how much of your disk is used by each directory.
The Challenge
The most important thing to learn from this lesson is getting "meta-data" from files, and walking a directory. Walking the directory happens in the du utility, and it means to start at the top of a directory tree and visit every child directory and file.
Go has several equally annoying ways to walk a directory structure, so I'll just tell you to use filepath.WalkDir. There are about 3-4 other ways but this one is the easiest to use.
You'll also be required to use an anonymous function when you use filepath.WalkDir.
The documentation for these commands are:
Register for From Impostor to Programmer
Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.