Environment Variable:

The directories where you want to store the Configuration File and frequently used pattern files are specified with the "QTGREP" environment variable in the same manner as directories are specified with the "PATH" environment variable.  See the instructions for your shell for setting environment variables.

Note that the environment variable directories are used for the Configuration File and pattern files, but NOT for files to be scanned for matches.


Pattern Files:

QTGrep first attempts to open a pattern file in the current directory. If the pattern file is not found in the current directory, QTGrep uses the path specified in the HOME environment variable, if not found in the HOME directory, the directory or directories specified in the QTGREP environment variable are searched.

Configuration File: .qtgreprc

QTGrep attempts to open two Configuration Files.  QTGrep attempts to open the first, called the "global" resource configuration file, as:

  "/usr/local/etc/.qtgreprc".

If the global configuration file is found it is read and the directives executed.

QTGrep then attempts to open the second or "local" resource configuration file, as:

  "~/.qtgreprc"

If the local configuration file is found, it is read and the directives executed.

If both the global and local resource configuration files are found, any directives in the local configuration file over-ride those in the global configuration file except for the "Default Search Directory" directive. If this directive is present in both configuration files, the two search paths are concatenated, with the paths specified in the local configuration file searched first.

If no configuration file is found, then all options are set to FALSE (zero == 0) as appropriate.

QTGrep uses a Configuration File, predefined as ".qtgreprc", to preset all options and the colors used for highlighting under the ANSI, 'D', command line option. All command line options EXCEPT:

    'L' - display license,
    'W' - write compiled expressions to file,
    'f' - specify filename for patterns,

may be specified in the configuration file.

The following keywords are used in the configuration file to set the QTGrep options: (Note the corresponding command line option letter is also shown)

Keyword

Action
----------------------------

----------------------------
ANSI 
D
Turn ANSI highlighting On/Off
ANSI_match_foreground

Set match string foreground
ANSI_match_background

Set match string background
ANSI_normal_foreground

Set normal text  foreground
ANSI_normal_background

Set normal text  background
ANSI_filename_foreground

Set filename     foreground
ANSI_filename_background

Set filename     background
ANSI_end_foreground

Set end program  foreground
ANSI_end_background

Set end program  background
Buffer
B
Turn scan file buffering On/Off
Cumulative
C
Turn cumulative count On/Off
RecLen
E
Set fixed Record Length
Force_Filename
F
Force Filename on Output
Filename_On_First_Match_Only
H
Filename on First Match Only
MatchIndex
I
Output Match String index and Length
Keyword
K
Force keyword Search
MatchString
M
Output Match String
PatNumber
N
Output Match Pattern Number
NoPrompt
P
No prompt Pattern from Std Input
RegularExp
R
Force Regular Expression Search
Recurse
S
Recurse subdirectories
Tagged
T
Output Tagged Strings
PCDOS
U
Turn MS/PC-DOS Records On/Off
U**x
X
Force U**x style records
PreviewFiles
Z
Preview Filenames only
ALLMatches
a
Force Finding All Matches
ReverseSearch
b
Force Backward Search
MatchCountOnly
c
Output Count of Matching Lines Only
Embed
e
Output Embedded Matches
NoFilenames
h
No filenames on Output
IgnoreCase
i
Ignore Case in Search
FilenameWidth
j
Set Filename width on output
CountEachFile
k
Output match count for each file
LongestMatch
l
Find Longest match
MatchStop
m
Set number of matches to stop on
Recordnumbers
n
Output Record Numbers with match line
FilenameOpened
o
Output Filename when opened
PromptPat
p
Prompt Pattern from Std Input
TranslateAndQuit
q
Translate Patterns, output and quit
Replace
r
Force Replacement of Patterns
TotalCount
s
Output Total match and Record count
UpperCase
u
Force input to Uppercase
NoMatch
v
Force output of records not matching
UorDOS
x
either U**x or DOS style records
SimReplace
z
Force Simulation of replacing matches
Default Search Directory = xxxxx

Specify Search paths for pattern files

The following resource configuration file directive sets the search path for pattern files. If both a global, /usr/local/etc/.qtgreprc", and local resource configuration file, "~/.qtgreprc" are utilized and both specify a search path, the search paths will be concatenated and both used. Thus, the global configuration file can specify the path to system-wide pattern files and the local configuration file can specify the path for the user's own pattern files.

Default Search Directory = ~/qtawk-fn/

Note that this directive may occur more than once in a configuration file. The paths specified in the later occurrances, are searched before those in the previous occurrances. 

QTGrep recognizes ONLY those lines which match the pattern for keywords and the value expected for that keyword.  All other lines are ignored. Note that case, uppercase or lowercase, is ignored in searching lines for a match.

For keywords, the entire keyword must be used, substrings of the keywords are NOT matched. For setting the colors used in the screen highlighting, the acceptable minimum substrings are indicated below.

The following is an example configuration file. Comment lines are indicated by '#'. This is for readability only and to prevent QTGrep from matching undesired lines.


  # set ANSI output ON or OFF
  # -D command Line switch
  # OFF default
  #ANSI = On/OFF
  #ANSI = OFF
  ANSI = On

  #set ANSI output colors
  # -D command line switch
  #
  #  colors available for specification are: Note the minimum needed to
  #   specifiy a given color are as shown - only the minimum are read
  #   to determine which color to use
  #   Black     -- bla
  #   Red       -- r
  #   Green     -- g
  #   Yellow    -- y
  #   Blue      -- blu
  #   Magenta   -- m
  #   Cyan      -- c
  #   White     -- w
  #   default   -- d == default screen color, foreground or background
  #
  # Colors May Be Modified With The Following Attributes:
  #  (minimum string needed to recognize shown in parenthesis)
  #   hi         (hi)  --> high intensity
  #   underscore (un)  --> underscore (Monochrome Display ONLY)
  #   blinking   (bl)  --> blinking
  #   reverse    (rev) --> reverse video
  #   hidden     (hid) --> hidden ( Foreground color == background color)
  #
  #  Defaults are:
  #  match string    --> high intensity green on blue
  #  normal   text   --> default screen colors
  #  filename text   --> white on blue
  #  program   end   --> default screen colors
  #
  #  match string
  ANSI_match_foreground = Hi Green
  ANSI_match_background = default
  #
  #  normal text
  ANSI_normal_foreground = default
  ANSI_normal_background = default
  #  filename text
  ANSI_filename_foreground = blue
  ANSI_filename_background = default
  #
  #  program end
  ANSI_end_foreground = default
  ANSI_end_background = default

  # specify whether Record/Buffer operation on scanning
  # -B option
  # On default
  #Buffer = ON/OFF
  #Buffer = Off
  #Buffer = ON

  # Specify whether Cumulative Match & Record Count is output
  # -C option
  # Off default
  #Cumulative = ON/OFF
  #Cumulative = On
  #Cumulative = Off

  # Specify Fixed Record Length - setting to Zero turns off
  # fixed length records
  # -E option
  # 0 default
  #RecLen = 0
  RecLen = 0

  # Specify whether to force filename on output
  # -F option
  # Off default
  #Force_Filename = ON/OFF
  #Force_Filename = On
  #Force_Filename = OFF

  # Specify whether to force filename only before first match
  # -H option
  # Off default
  #Filename_On_First_Match_Only = On/Off
  #Filename_On_First_Match_Only = On
  #Filename_On_First_Match_Only = Off

  # Specify whether to output Match Index and length
  # -I option
  # Off default
  #MatchIndex = ON/OFF
  #MatchIndex = On
  #MatchIndex = Off

  # Specify forced Keyword Search
  # If BOTH Keyword and RegularExp options OFF, then QTGrep
  # determines which to use from expressions
  # -K option
  # Off default
  #Keyword = ON/OFF
  #Keyword = OFF
  #Keyword = On

  # Specify whether to output match string
  # -M option
  # Off default
  #MatchString = ON/OFF
  #MatchString = On
  #MatchString = Off

  # Specify whether to output matching pattern number
  # -N option
  # Off default
  #PatNumber = ON/OFF
  #PatNumber = Off
  PatNumber = On

  # Specify whether to obtain patterns from
  # Standard Input, NoPrompt
  # -P option
  # Off default
  #NoPrompt = ON/OFF
  #NoPrompt = OFF
  #NoPrompt = On

  # Specify Forcing Regular Expression Search
  # If BOTH Keyword and RegularExp options OFF, then QTGrep
  # determines which to use from expressions
  # -R option
  # Off default
  #RegularExp = ON/OFF
  #RegularExp = OFF
  #RegularExp = On

  # Specify whether to recurse sub-directories
  # -S option
  # Off default
  #Recurse = ON/OFF
  #Recurse = OFF
  #Recurse = On

  # Specify whether to output tagged strings
  # -T option
  # Off default
  #Tagged = ON/OFF
  #Tagged = On
  #Tagged = Off

  # Specify whether Unix style or PC-DOS style records
  # Switch record delimitor to CR/LF
  # -U option
  # On default
  #PCDOS = ON/OFF
  #PCDOS = ON
  #PCDOS = Off


  # Specify whether to Verbosely output count of matching lines ONLY
  # -V option
  # Off default
  #VerboseMatchCountOnly = ON/OFF
  #VerboseMatchCountOnly = OFF
  #VerboseMatchCountOnly = On

  # Specify whether Unix style or PC-DOS style records
  # Retain single LF record delimitor
  # -X option
  # On default
  #U**x = ON/OFF
  #U**x = ON
  #U**x = Off

  # Specify Whether to do a file preview
  # -Z option
  # Off default
  #PreviewFiles = ON/OFF
  #PreviewFiles = OFF
  #PreviewFiles = On

  # Specify whether to find all or first match
  # -a option
  # Off default
  #ALLMatches = ON/OFF
  #ALLMatches = OFF
  #ALLMatches = On

  # Specify whether to do forward or reverse search
  # -b option
  # Off default
  #ReverseSearch = ON/OFF
  #ReverseSearch = OFF
  #ReverseSearch = On

  # Specify whether to output count of matching lines ONLY
  # -c option
  # Off default
  #MatchCountOnly = ON/OFF
  #MatchCountOnly = OFF
  #MatchCountOnly = On

  # Specify whether to output embedded matches
  # -e option
  # Off default
  #Embed = ON/OFF
  #Embed = OFF
  #Embed = On

  # Specify that no filename headers are to be output
  # -h option
  # Off default
  #NoFilenames  = ON/OFF
  #NoFilenames  = Off
  #NoFilenames  = On

  # Specify whether to ignore or consider case in search
  # -i option
  # Off default
  #IgnoreCase = ON/OFF
  #IgnoreCase = On
  #IgnoreCase = Off

  # Specify Filename field width spcification, setting to zero
  # defaults to actual filename width
  # -j option
  # 0 default
  #FilenameWidth = 0
  #FilenameWidth = 12

  # Specify whether to output count of match at end of
  # each file scanned
  # -k option
  # Off default
  #CountEachFile = ON/OFF
  #CountEachFile = On
  #CountEachFile = Off

  # Specify whether to find longest or shortest match
  # -l option
  # Off default
  #LongestMatch = ON/OFF
  #LongestMatch = OFF
  #LongestMatch = On

  # Specify whether to stop after specified number of matches
  # in file setting to zero finds all matches in each file
  # -m option
  # Off default
  #MatchStop = 0
  #MatchStop = 0

  # Specify whether to output records numbers
  # -n option
  # Off default
  #Recordnumbers = ON/OFF
  Recordnumbers = On
  #Recordnumbers = Off

  # Specify whether to output filename to be scanned
  # when file opened
  # -o option
  # Off default
  #FilenameOpened = ON/OFF
  FilenameOpened = On
  #FilenameOpened = Off

  # Specify whether to prompt for patterns from the
  # standard input file
  # -p option
  # Off default
  #PromptPat  = ON/OFF
  #PromptPat  = Off
  #PromptPat  = On

  # Specify whether to translate search expressions into
  # regular expression and output then quit
  # -q option
  # Off default
  #TranslateAndQuit = ON/OFF
  #TranslateAndQuit = Off
  #TranslateAndQuit = On

  # Specify whether to replace matches, use filename specified,
  # null filename turns off
  # -r option
  # Off default
  #Replace = ON/OFF
  #Replace = On
  #Replace = Off

  # Specify whether to output count of all matches across all
  # files when finished
  # -s option
  # Off default
  #TotalCount = ON/OFF
  #TotalCount = On
  #TotalCount = Off

  # Specify whether to translate file search file to uppercase
  # before search Use of the "IgnoreCase" option would be a better
  # alternative
  # -u option
  # Off default
  #UpperCase = ON/OFF
  #UpperCase = Off
  #UpperCase = On

  # Specify whether to output only records not matching a pattern
  # -v option
  # Off default
  #NoMatch = ON/OFF
  #NoMatch = Off
  #NoMatch = On

  # Specify whether to accept either U**x or DOS style records
  # -x option
  # off default
  #UorDOS = ON/OFF
  #UorDOS = on
  #UorDOS = off


  # Specify whether to simulate replacing matches, no actual replacement,
  # see the "Replace" option
  # -z option
  # Off default
  #SimReplace = ON/OFF
  #SimReplace = Off
  #SimReplace = On

  # Specify Search directory for epattern files
  # If none specified, only current directory searched
  # the following line would probably be used in the global
  # resource configuration file:
  Default Search Directory = /usr/local/share/QTAwk/
  # The following line would probably be used in the local
  # resource configuration file:
  Default Search Directory = ~/qtawk-fn/

© Terry D. Boldt 1997-2005
All Rights Reserved
Last Updated: Feb. 03, 2005