Homepage
     Computer-related issues:
            Program library
                  Programs sdir and sdirstat
                  Programs splitpath and splitenv
                  Program chendl
            System administration:
                  Installation of cdma-modem
     Law:
         Constitution of RF with subject index



SDIR and SDIRSTAT

SDIR: a small free-distributed UNIX (LINUX) program,
which scans the directory hierarchy and executes any command, and
SDIRSTAT: a "sister" (still experimental) program,
which simply scans the directory hierarchy and using inbuilt algorithms
obtains statistics about file extensions, numbers of them,
their sizes and numbers of lines in them.



The typical application of sdir program is running a grep program in each subdirectory and finding a key-word in a files with certain name extension:

sdir -tpwa "grep keyword *.ext"

The typical applications of sdirstat program is extracting from a complicated directory trees a cumulative lists of files in chronological order (the newest are usually wanted):

sdirstat -T

or obtaining estimations of amount of lines-of-code in a complicated source code depositories:

sdirstat -ALSUC

The full sdir manual in man-like format.
The full sdirstat manual in man-like format.
The compressed tar-archive with both programs.

The current version of sdir program is 2.2 and issued 17.12.2008. The current version of sdirstat program is 2.4 and issued 22.12.2008. The (man-formatted) manuals of sdir and sdirstat are upgraded: 07.07.2008.

Also see other (not related anyhow to sdir package) simple programs that format environment variables in a readable convenient way: The split package.
and simple program that analyse and change format of end line symbols of text files in Linux and Windows: The chendl program.

Here in the following we will consider only sdir (and sdirstat).

What is this?

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.

Сайт управляется системой uCoz