![]() ![]() The challenge with stepping through the directories in the PATH is that the fields are not separated by spaces but rather by the colon (“:”) symbol. No worries, the script is going to be portable, which is one of the great joys of Linux, Unix, and its related operating systems. I’m running these tests on my Mac system, which has a full Linux-esque system accessible through the Terminal app, which is why I might have a few that are different to what you’ll see, most notably the VMware Fusion directory. bin:/usr/sbin:/sbin:/Applications/VMware Fusion Tech Preview.app/Contents/Public opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin: The most important is the PATH and that can be very easily displayed as shown: $ echo $PATH You can try it yourself to see what’s shown, but it’s typically 12-20 different variables, including a few oddities like _=/usr/bin/env. All system variables of this nature are in all-caps, and you can see every one in your own interactive shell by typing the command env. There are a half-dozen or so system settings that are set as part of your interactive shell instantiation, including HOME, USER, SHELL, and PATH. Let’s check it out, step by step… HOW TO STEP THROUGH YOUR $PATH ![]() There are three pieces to this script that will need to be solved: How to count total files, how to count executables, and how to step through directories listed in the PATH. ![]() Okay, back on task! Now, let’s start breaking down the task, because, like any other programming project, the key to success is to divide and conquer. Heck, I’ve written quite a few books about Unix and Linux too, including the best-selling Wicked Cool Shell Scripts that I recommend both to you and your instructor. I’m also a long-time Linux user, and Unix before that, so I have a very positive association with the command line too, which is why I’m happy to help you out with this. There are also millions of systems on the Internet that are running Linux, and while Linux has graphical interface options, a lot of developers prefer to crack open the command line for their power tasks. While the vast majority of our interaction with computers nowadays is through graphical interfaces (think smartphone) or voice ( Alexa devices), there are still cases where a command line interface and a keyboard input is the most efficient form of interaction. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |