Previous Up Next

19  asgrep

19.1  License

asgrep is Copyright 2000-2003 by Ascher Stefan and Danail Traichev.

This program is freeware. You are allowed to use and distribute asgrep for free, but you are not allowed to sell asgrep for profit. You are using asgrep at your own risk, no responsibility is taken for damages to your computer system. The Source Code is provided under the Mozilla Public License, see Appendix C.

19.2  Introduction

asgrep is a Find in Files utility which supports regular expressions (16), multiple filemasks with wildcards and searches recursively all subfolders if requested. Additionally you may replace matches with another text with support for escape sequences. Unfortunately it's not that fast as Borlands Turbo Grep is. Sure, there are sitting lots of professionals, and I'm just a novice ;-).

This is a console program, i.e. it has no graphical user interface, so you can easily integrate it in your own program, e.g. as syn does.

19.3  Command line switches

asgrep [-di <folder(s)>] [-fi <filename(s)>] [-ft <findtext>] 
[-rt <replacetext>] [-cf <configfile>] [switches]

19.4  Using a configuration file

If you have a lot of files and/or directories to search, in general when the command line becomes rather long, you should use a configuration file. This file is similar to an ini-file:
; The text to look for
; use 1 for match case, otherwise 0.
; Replace the found match with this text
; Do replace the found text with replacetext
; Backup files before replacing
; Replace text contains Escape Sequences
; Search also binary files
; Skip binary files
; Format is either for example "*.htm;*.html" or "*.htm, *.html"
; force the program to wait the specified amount of milliseconds
; before it searches a file
; for recurse search from the given dirs (search all subfolders) use
; searching for whole words only use
; use Regular Expression, can't be combined with wholewords
; Shows only the count of found Matches

; All files you want to search.
; count of the filelist
; ...

; All directories you want to search.
All command line arguments are overwritten by the configuration file, except files and directories, which are added to the list. If an option is not given in the file, but in the command line, it will use the option from the command line. Should it be so, shouldn't the command line arguments overwrite the configuration file? Hm, not sure, give me a hint.

If you replace text, binary files are automatically skipped, because it can't correctly replace text in binary files. Before you replace text in files you should make a backup copy of these files.

19.5  Results

Matches are written in the console window (StdOut), you can see the filename, the line and column number and the linetext. One emitted line can look like this, when you have display lines on, and report match count only off:
D:\Eigene Dateien\hp\download.htm: (72, 87):       This program uses the
<a href="" target="_blank">SynEdit</a>
The first part is the filename, 72 is the line number, 87 is the column number, and the last part is the line text: FileName: (line number, Column Number): Line text.

19.6  Replace text

It is possible to replace found matches with another text. To do so, provide the -rt switch followed by the new text. If your replace text contains escape sequences (17), and you wish to substitute them by the corresponding character provide also the es+ switch. If you additionally use the bk- switch it does not backup files before replacing text in them.

19.7  Credits

Previous Up Next