The command sdir scans directories starting from the current directory, and passing through all directory tree originated from the current directory (visiting all its subdirectories and for each of them visiting its subdirectories etc.), possibly (if requested) prints their names and possibly (if requested) executes any command in each (sub)directory. Sdir changes the current directory to each of the passed subdirectories and runs the target command once per directory.
Trivial, but everyday example. To list the subdirectories of the current directory, by the same way as the "ls" lists files: type "sdir". You can also type "du", but then you will also receive the list of space occupped by files in the corresponding directories. Look at "sdir" manual for more details on these and other commands.
For more complicated example, to find definition (or just use)
of the macro DBL_MAX one can
switch to home of most of the include files related to C/C++,
that is /usr/include directory and run one of two commands:
find -name "*.h" -exec grep -H DBL_MAX {} ";
"
sdir -tpw "grep -H DBL_MAX *.h"
The first is longer and probably more difficult to remember, to type,
and to understand when it appears in a script.
The second is simplier. The both commands receive similar output.
The "find" program gives this:
-------------------program output-----------------------------------
./kpathsea/c-minmax.h:#ifndef DBL_MAX
./kpathsea/c-minmax.h:#define DBL_MAX 1e+37
./values.h:#define MAXDOUBLE DBL_MAX
./values.h:#define DMAXEXP DBL_MAX_EXP
-------------------end of program output-----------------------------
and the "sdir" program receives this:
-------------------program output-----------------------------------
-->.:
values.h:#define MAXDOUBLE DBL_MAX
values.h:#define DMAXEXP DBL_MAX_EXP
-->./kpathsea:
c-minmax.h:#ifndef DBL_MAX
c-minmax.h:#define DBL_MAX 1e+37
-------------------end of program output-----------------------------
Assuming that you are not beginner in computer activity, this output
could give you a hint that you should include into your C++ program
the file <values.h> or first just look into it.
If you prefere the last,
you will find there that you can also include <float.h>,
or you may guess according to the ordinary C++ practice,
that you can also include <cfloat>.
All possibilities will work.
At the top of this page you will find links to text file with complete manuals (in man-like format, that is a textual files obtained from groff-formatted files like "sdir.1" by "man /fullpath/sdir.1 | col -b > sdir_man.txt"). The manual of sdir contains not only description of "sdir" itself, but also a summary for the use of other file- and directory-related UNIX (LINUX) commands with "sdir" and separately. This can be useful of UNIX users. You will also find a link to the full tar-archive (compressed by "gzip") with source files of "sdir" and "sdirstat", executable files (compiled at Intel Pentium M processor with Scientific Linux SL release 4.1 (Beryllium) and gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)), installation instruction (a trivial!), ordinary man-page, mentioned above its textual translation, and GPL license according to which it is allowed to be distributed.
Send questions, constructive comments, proposals and bug reports to ibsmirnov at mail.ru
The page created 15.08.2007.
Last modified 22.12.2008.
I am going to mark noticable changes such as small change of interface (like adding more options) by increment of the second version number after dot. If major changes occur, such as principal change of program design or purpose (that is little probable), they will be marked by increment of the first number. The date of issue can be renewed without change of both version numbers, if the change in program is minor, technical or not noticable (removing blank line, small reconfiguration of the source text without meaningful change etc.), or if there is only change in manual (correction of typos, improving some section etc.).
The author of this site is grateful to the web-hosting provider for the space and for good operating possibilities, but he is not responsible and has no relation to advertisement icons if they appear at this site by the will of the web-hosting provider.
Author has also created and currently maintains another interesting page devoted to law. It represents index to constitution of Russian Federation from the perspective of human rights and it has the constitution itself. It is entierly in Russian (and in KOI8-R encoding). Here is the link.
Copyright (C) 2007, I. B. Smirnov.