|
Recent
Articles |
Linux Console, Terminal, Virtual Terminal & Linux... As part of your Linux training, you need to understand Linux terms to be able to understand Linux concepts. And learning Linux concepts helps you to learn how to use Linux! There are several Linux terms that are the...
Booting to a Linux Console vs. Linux Desktop As part of getting Linux training on Linux concepts, you need to learn Linux terms to understand the concepts. These articles, with names ending in "Linux Concepts & Terms", have been created to help you learn...
The Linux Programmer's Toolbox Wow. Regular readers here know I don't say "wow" lightly. I may like a book, I may even think it's useful or even something you really should have, but very...
Dell & Ubuntu: All About The Drivers So Dell has given some more details on its plan to fulfill one of the top 10 wishes of the people who submitted ideas to its Digg-style IdeaStorm site: It's going to...
Configuring NTP On Your Linux Server The Network Time Protocol (NTP) defines a set of algorithms for the dissemination of time across the Internet. The NTP protocol can be used to...
Linux Server Based Computing & Terminal... Being an IT consultant I get to visit lots of companies and can't help but notice any trends that are happening. One of these trends is more and more Linux servers (and occasionally workstations) appearing in...
|
|
|
06.27.07
Counting Executable Binaries On A Linux Box
By
Dave Taylor
I've been looking at your script to count executable binaries in the book Wicked Cool Shell Scripts and I think that there's a problem in the script. What happens if I have a directory in my PATH more than once?
Great point. The script you're talking about is called how-many-commands.sh:
The problem is indeed stuck in that script, because when I break down the PATH, I manage the problem of having spaces in the directories neatly (I convert them to '--' then convert them back after the "for" loop) but what if there's more than one occurrence of a directory in the path?
Turns out that's pretty easily done by having a bit more code in the myPATH statement:
Can you see what I added? Not too difficult, but I'm using the super-helpful "uniq" command to remove duplicates, but it doesn't work until you ensure that your path entries are in order, hence the use of the word "sort").
Now you'll have an accurate executable / non-executable file count for your system and your set PATH value.
Comments
About the Author: Dave Taylor has been involved with the Internet since 1980 and is
internationally known as an expert on both business and technology issues.
Holder of an MSEd and MBA, author of twenty books and founder of four
startups, he also runs a strategic marketing company and consults with firms
seeking the best approach to working with weblogs and social networks. Dave
is an award-winning speaker and frequent guest on radio and podcast
programs.
AskDaveTaylor.com
http://www.intuitive.com/blog/
|