Команды SFK


    1        2        3        4        5        6        7        8        9        10    

Раздел 4. Text Processing - Обработка текста
addhead | addtail | count | difflines | filter | head | joinlines | linelen | load | ofilter | perline | printloop | replace | run | runloop | snapto | sort | strings | tail | xed | xex | xreplace |


Help:   Рус   |   Eng        Refer:   Рус   |   Eng  

Команда: snapto

collect thousands of text files, e.g. java or c++ source code, into one large file for fastest loading and searching.

free open source tool for the Windows command line, Mac OS X Terminal, Linux shell or Raspberry Pi.

there are several ways to search text within 3000 text files:

1.)   let your IDE/editor scan the files directly on hard disk.

this will take at least 30 seconds, or even several minutes.

2.)   index files on hard disk, then scan them.

IF your files are indexed already, this will only take seconds.
but in most cases, the index is "out of sync", and after the
sync is done, depending on your IDE, you may have to click
once for every hit to view it's context. but every superfluous
click is a boring waste of time.

3.)   collect all text files into one large text file,
then load this within an editor or IDE.

it's simple: loading one large file is at least 10 times faster
then loading many small files. therefore sfk snapto was created.

on the command line, cd into the toplevel of your working tree,
then say

sfk snapto=all-src.cpp .

which means "collect all text files from the current dir (.),
including all subdirectories, into all-src.cpp".

when this is done, load all-src.cpp into you favourite editor
and run some searches. you will see that jumping through
results across everything has become much easier and faster.

4.)   collect all text files into one large text file,
then load this within depeche view.

as an extension to the above example, say

dview all-src.cpp

the snapfile is loaded. now, to search anything, just type
the word, wait one or two seconds, then use MOUSE WHEEL DOWN
(or SHIFT+CRSR DOWN for notebook users) to fly through
the results.

5.)   alternatively, let depeche view load a directory tree directly,
without creating a snapfile:

cd into your favourite working dir, then say

dview .

and depeche view will load and display all text files instantly.

6.)   how to include also binary files:

to collect text files AND .doc .ppt .xls contents from mydir:

sfk snapto=all.txt mydir -all .doc .ppt .xls

only ASCII text portions will be extracted from .doc, .ppt and
.xls files. all binary content will be ignored.

alternatively, to view the same contents directly:

dview mydir -all .doc .ppt .xls


it is recommended to use snapfiles on very large directory trees,
and to load the tree directly on smaller ones. for more infos
about depeche view, read on here.