SCANjobs - SCAN for patterns in 1 or all files in directory - contents

These jobs will be especially useful to programmers who wish to make mass changes to source programs or to entire directories of programs.

They could also be used by anybody who wants to search & replace data in any ASCII text file or directory of files.

A1. Introduction to the SCANjobs
A2.  SCANjobs vs grep, when to use which.
B1. Test/demo files supplied to demonstrate the SCANjobs
 tf/names1, tf/names2, tf/test100

Features common to most SCANjobs

C1. command line arguments (arg1-arg9) standard assignments
C3.  user options (uops) for scan begin/end by line# & column#
C4.  pattern match characters (@=any alpha, #=any numeric, etc)
C5.  table types 1 & 2 for scan by table jobs (scan2 & scan2d)
D1. scan1 - scan a text file (or source program) for any 1 pattern
  & print out all matching lines with their line#s
- the filename & the pattern may be specified on the command
  line or if omitted, they will be solicited from the operator.
- a 2nd pattern (qualifier) may be coded which must be present.
- a 3rd pattern (qualifier) may be coded which must NOT be present.
D8. - 8 demo runs (command lines & test results)
E1. scan1d - same as scan1 but processes all files within a directory
- useful when making changes that could affect several files
- run this job using a relevant keyword(s) to find all the files
  and line#'s that may require changes. Print the audit report &
  use it as your guide when making changes with vi.
F1. scan2 - scan a text file for matches to a pre-edited table file &
  create a report with matching lines & their line#s
- the table has 3 columns: search patterns, presence qualifiers,
  & absence qualifiers (pattern lengths determined by 1st tilde)
- there are many options including 2 table types:
  type1 - qualifiers apply only to search pattern on that line
  type2 - search patterns & qualifiers are independent
F1. - 4 demo runs (command lines & test results)
G1. scan2d - same as scan2 but processes all files within a directory
  using the same table format as scan2.
H1. scan3d - scan all files in a directory & select records to an audit file
  that lie between any 2 specified patterns (start/stop) &
  optionally qualified by a 3rd pattern that must be or must not
  be present between the 1st 2 patterns.

Goto:   Begin this document End this document UVSI Home-Page

SCAN for patterns in 1 or all files in directory - contents continued

I1. count1d - scan all files in a directory reporting lines containing
  specified occurrences of up to 3 patterns. Match conditions
  may be equal, less than, greater than or not equal (=<>!).
J1. count2d - scan all files in a directory for up to 3 patterns with
  specified counts & conditions <=!> for each pattern & count
- reports only file-names not data contents as do other jobs
- patterns may be anywhere in file, not necessarily on same line
K1. scan1t - scan files for a pattern within a line# range & qualified
  by 1 or 2 other patterns which also have line# ranges.
- The qualifier line# ranges can absolute or relative to the
  line# of the matching search pattern.
- this job tables the entire file in memory, allowing 20,000
  lines of 100 bytes.
K2. scan1td - same as scan1t above, but reads all files in the directory.
- you would use scan1t for testing, but scan1td for real work.
L1. scan3td - scan for a pattern that must be followed by a 2nd pattern
  before encountering a 3rd pattern
  (which may be same as 1st pattern)
M1. scan4d - scan a directory searching for matches to a table of patterns
- report filenames with at least 1 match, or with no matches
- this job reports only the filenames
- use scan2d to report the text lines containing the matches
N1. makesf1 - build [& execute] commands for all filenames in a text file
- example generate 'vi' commands for all files found by a
  preceding 'grep'. Filenames identified by '/' & a qualifier.
N2. makesf2 - same but creates multiple filenames on 1 command.
N3. makesf3 - same but creates multiple filenames on 1 command, and breaks
  into multiple lines using '\' continuation.
O1. Job listings - parameter files of uvcopy interpretive instructions.
- listed at the end of the section in the same sequence as the jobs
  were documented at the front of the section.

This section (SCANjobs) documents the 'scanning' jobs which are very useful to investigate & determine the scope of a potential problem. Specify 1 or several unique patterns that identify the potential problem & these jobs will create reports showing the filenames & line numbers that include the specified patterns.

If the number of occurrences is low you would fix the problem using the editor, guided by the 'hit' report with filenames & line numbers. If the number of occurrences is large, you could use the 'rep' jobs in the next section (REPjobs) to automatically fix the problem if it is the type of problem that can be fixed by pattern replacement (singly or by table).

Goto:   Begin this document End this document UVSI Home-Page

A1. Introduction - general purpose search & report utility jobs

If you have just received this package, you can run these jobs immediately (before you learn the uvcopy instruction set) since these jobs solicit your filenames & the patterns you wish to scan for. If you want to replace the patterns with alternates, see the next section (REPjobs.doc).

To familiarize you with these jobs I have provided test files, detailed operating instructions,& expected results. Please run these & compare your results to the expected results. This exercise is also a good way to verify the installation & correct operation on your particular hardware/software system architecture.

Note that all these jobs produce a detailed 'audit' file containing the matched lines & total statistics. If you wish to make some mass changes to your files, I suggest you would 1st run 1 of the 'scan' jobs with your search patterns & check the audit file for expected results before running the appropriate 'rep' job to actually perform the replacements. In any case these jobs always copy to another file or another directory which you may inspect before changing the output names back to the original.

Note that these jobs are intended for processing variable length ASCII files terminated by linefeeds (such as text & programs).

To process fixed length data files, please see several similar jobs in section COPYjobs.doc. You could use the scanning jobs in this section on fixed length files that have linefeeds in the last byte but replacing jobs with unequal replacements would destroy the fixed length.

Also note that the maximum record length processed by the SCANjobs is 256 bytes, but you could easily increase these lengths if required. For example, if you wanted to change to 1024, you would change 256 to 1024 on the fili, filo, get, put, mvc's that move record,& the various 'scn' instructions that scan the record.

scan1 & scan2 vs scan1d & scan2d

Scan1 & scan2 process only 1 file at a time, whereas scan1d & scan2d process all files in the directory. Scan1 & scan2 are useful for testing your scan patterns & qualifiers before using scan2 & scan2d to process the entire directory.

Scan1 & scan2 are also convenient for education & most of the demo's in this section will use these jobs, but of course all features illustrated also apply to the more important scan1d/scan2d.

Goto:   Begin this document End this document UVSI Home-Page

A2. SCANjobs: general purpose Search & Report pre-programmed uvcopy job

SCANjobs vs 'grep' - when to use which

The UNIX 'grep' utility is faster, but you might want to use SCANjobs when you need 1 of the following features:

  1. Use SCANjobs when you want a formatted report showing line#s, etc. These reports are useful for assigning editing tasks to junior programmers.

  2. Use SCANjobs when you need qualifiers - other patterns that must also be present &/or not present on the same line as the search pattern.

  3. Use SCANjobs when you need to restrict your search by column# or line#. Example - you can scan COBOL programs only on the text area cols 8-72, to avoid matching data in cols 1-7 or 73-80. Example - you can scan documents on specified line# ranges. - Could start scans at line #55 to avoid matches on title pages.

  4. If you are scanning COBOL programs, you can use 'cobscan1d', which is documented in section COBscan.doc. This job will scan the COBOL statement, which could be spread over multiple lines. This is important if you are using present/absent qualifiers with your search pattern.

  5. Some general purpose SCANjobs such as scan3d provide multi-line scanning. 'scan3d' will find patterns which must be present between other lines with other specified qualifying patterns.

Goto:   Begin this document End this document UVSI Home-Page

B1. TEST FILES provided to demonstrate SCANjobs

Directory 'tf' contains several test files that will be used by these jobs which are contained in directory 'pf' (parameter files for uvcopy). The most commonly used files are listed here so you can compare the illustrated results to the original file.

tf/names1 - 6 sets of Name & Address - separate lines

Owen Townsend UV Software 5436 Victoria Dr Vancouver BC Canada V5P 3V8

Glen Clark Premier of BC 1234 Government St. Victoria BC Canada V1P 2G3

Mike Harris Premier of Ontario 1234 University Ave Toronto Canada M5W 1E6

J. Chretien Prime Minister 24 Sussex Drive Ottawa, Ontario K1Y 2L6 Canada

Bill Clinton President of USA 1600 Pennsylvania Ave. Washingtom DC 00001 USA

Bill Gates Microsoft Corp. 1 Microsoft Way Redmond, WA USA 98052-6399

tf/names2 - 6 sets of Name & Address - delimited

Owen Townsend;UV Software;5436 Victoria Dr;Vancouver BC Canada;V5P 3V8 Glen Clark;Premier of BC;1234 Government St.;Victoria BC Canada;V1P 2G3 Mike Harris;Premier of Ontario;1234 University Ave;Toronto Canada;M5W 1E6 J. Chretien;Prime Minister;24 Sussex Drive;Ottawa, Ontario;K1Y 2L6 Canada Bill Clinton;President of USA;1600 Pennsylvania Ave.;Washingtom DC;00001 USA Bill Gates;Microsoft Corp.;1 Microsoft Way;Redmond, WA USA;98052-6399

Goto:   Begin this document End this document UVSI Home-Page

B2. TEST FILES provided to demonstrate SCANjobs - continued

tf/test100

 0001 tf/test100 one
 0002 tf/test100 two
 0003 tf/test100 three
 0004 tf/test100 four
 0005 tf/test100 five
 0006 tf/test100 six
 0007 tf/test100 seven
 0008 tf/test100 eight
 0009 tf/test100 nine
 0010 tf/test100 ten
 0011 tf/test100 eleven
 0012 tf/test100 twelve
 0013 tf/test100 thirteen
 0014 tf/test100 fourteen
 0015 tf/test100 fifteen
 0016 tf/test100 sixteen
 0017 tf/test100 seventeen
 0018 tf/test100 eightteen
 0019 tf/test100 nineteen
 0020 tf/test100 twenty
 0021 tf/test100 twenty one
 0022 tf/test100 twenty two
 0023 tf/test100 twenty three
 0024 tf/test100 twenty four
 0025 tf/test100 twenty five
 0026 tf/test100 twenty six
 0027 tf/test100 twenty seven
 0028 tf/test100 twenty eight
       - - - etc - - -
 0099 tf/test100 ninety nine
 0100 tf/test100 one hundred

You might find tf/test100 a convenient test file to use when exploring the capabilities of the various scan jobs such as scan1 or scan2.

The advantage of tf/test100 is that the results are predictable, you can instantly evaluate the results of your scans for various patterns with various qualifiers, for example:


 uvcopy scan1,fili1=tf/test100,arg1=nine,arg2=~,arg3=ninety
 ==========================================================

This would report lines with 'nine' but not if 'ninety' was also present (see the audit reports on pages D6 & D7).

Goto:   Begin this document End this document UVSI Home-Page

C1. SCANjobs: arguments - search patterns, qualifiers, options , etc

You can run the scanjobs specifying only the jobname & you will be prompted for the various filenames, patterns,& options, OR you can specify all parameters on the command line to avoid the prompts, OR you can specify some of the prompts on the command line & you will be prompted for the unspecified parameters.

The following examples will be based on 'scan1' which will scan only 1 file searching for any 1 pattern creating a report with matching lines, their line#s,& total matches by file.

scan1 is good for illustrations because it only processes 1 file, however scan1d is much more useful because it processes all files in a directory. (ie - you would probably use 'vi' for 1 file, but scan1d for a directory)

Note that scan2 & scan2d do not use arg1,arg2,arg3 because the search patterns & qualifiers are specified in a table.


 uvcopy scan1      - will prompt for filename, arguments,& options
 =============
                   - commands below specify all arguments (no prompts)
                     but I recommend you specify the files & arg1 on the
                     command line so you can repeat with KORN shell history
                   - omit args2-9 & replay null to the prompts

 uvcopy scan1,fili1=file,arg1=search-pat,arg2=qual-present,arg3=qual-absent
 ==========================================================================
      ,arg6=scanbgn,arg7=scanend,arg8=match-optns,arg9=viewer,uop=user-optns
      ======================================================================

 ex#1: uvcopy scan1,fili1=tf/names1,arg1=Vancouver,arg2=BC
       ===================================================

 ex#2: uvcopy scan1,fili1=tf/names1,arg1=vancouver,arg2=bc,arg8=i,arg9=vi
       ==================================================================

 ex#3: uvcopy scan1,fili1=tf/names1,arg1=Vancouver,arg2=BC,uop=q0a6b30c4d40
       ====================================================================

 ex#4: uvcopy scan1,fili1=tf/names1,arg1u=V5P_3V8,arg2=~,arg3=~,arg8=n
       ===============================================================

 ex#5: uvcopy scan1,fili1=tf/names1,arg1u=@#@_*#@#,arg2=~,arg3=~,arg8=n
       ================================================================
note
  • option 'u' of 'arg1u=V5P_3V8' & 'arg1u=@#@_*#@#' causes the
    UNDERSCORE to be converted to a BLANK when stored by uvcopy.
    (since embedded blanks are not allowed on the command line)

Goto:   Begin this document End this document UVSI Home-Page

C2. arguments - search patterns, qualifiers, options, etc

These arguments may be specified on the command line of the various SCANjobs & REPjobs (see the examples on the previous page). Any unspecified arguments will be solicited by the job.

arg1
  • search pattern (must be specified, 64 bytes max)
  • prefix 0x indicates hex, 0x2C for a comma
arg2
  • qualifier present (optional)
  • may disable on the command line by specifying 'arg2=~'
  • may disable at the prompt by a null entry (or a '~' entry)
arg3
  • qualifier absent, or 2nd present if option p2
  • may disable on the command line by specifying 'arg2=~'
  • may disable at the prompt by a null entry (or a '~' entry)
note
  • some jobs combine arg2 & arg3 into 1 arg by using a leading
    '=' or '!' to indicate present or not-present, for example:
  • 'arg2==BC' means 'BC' present, 'arg2=!BC' means 'BC' not-present.
arg4
  • for the REPjobs, arg2 will be the replacement pattern, arg3 becomes
    the present qualifier,& arg4 becomes the NOT present qualifier.
arg6
  • pattern to begin scanning for search pattern (optional)
  • also see alternative uop=a1 to begin scan by data file line#
  • if arg6 not coded on the command line, you may cause the prompt
    for the begin scan pattern by specifying 'uop=a0'
arg7
  • pattern to end scanning for search pattern (optional)
  • also see alternative uop=b99999 to end scan by data file line#
  • if arg7 not coded on the command line, you may cause the prompt
    for the end scan pattern by specifying 'uop=b0'
 arg8 (match options):
        q3 - inhibits scanning within quotes (q1=single + q2=double)
        i  - case insensitive (patterns must be entered in lower case)
        p  - pattern match chars (@=any alpha,#=any numeric,etc)
        n  - may specify on the command line to disable the prompt
arg9
  • report disposition: vi,cat,lp,uvlp, etc

notes

Arguments 1,2,3,& 4 apply to scan1,scan1d,rep1,& rep1d,, but not to scan2,scan2d,rep2,or rep2d,, because the latter jobs use table files to specify their search arguments & qualifiers.

Option 'u' may be specified to convert underscores to blanks in the arg patterns eg: arg1u=V5P_3V8 (since embedded blanks are not allowed on the command line)

Goto:   Begin this document End this document UVSI Home-Page

C3. SCANjobs: user options (uops) - for misc numeric values

user options are a convenient way of specifying various numeric values using the 26 alpha letters followed by the numeric value

 used for specifying: scan begin/end by line#s & column#s,& table type#

user option display & prompt for change

 uop=q1a1b99999c0d128p1   - option defaults
       a1                 - begin scan at line #1 (default) of input file
       a0                 - causes prompt for search pattern to BEGIN scan
         b99999           - end scan at line #99999 (dflt) of input file
         b0               - causes prompt for search pattern to END scan
               c0         - begin scan at col #1 (zero rel) of input lines
                 d128     - length of scan area default 128 bytes
                     p1   - 1 presence qual(31-60) & 1 absence qual(61-80)'
                     p2   - 2 presence quals(31-60)+(61-80) & NO absence quals'
                       t1 - table type #1 for scan2, scan2d
                       t2 - table type #2 for scan2, scan2d (see next page)

User OPtion (uop) defaults = q1a1b99999c0d128 null to accept or re-specify (1 or more) -->

reply examples

    accept or respecify -->         <-- null to accept defaults
    accept or respecify --> a20b90  <-- would change scan begin/end line#s
                                        from default 1/99999 to 20/90
    accept or respecify --> c20d10  <-- would change scan begin/end column#s
                                        from default col 1 for length 128
                                        to column 21 for length 10
    accept or respecify --> t2      <-- would change default table type
                                        from type 1 to type 2
                                        (scan2 & scan2d only)

Goto:   Begin this document End this document UVSI Home-Page

C4. SCANjobs: Pattern Match Characters

The pattern match character option is activated via the 'p' option on the 'scn' instruction (scnp). See complete details in the uvcopy instruction detail documentation.

The complete set of available pattern match characters are:

       @ - any alpha
       > - any upper case alpha
       < - any lower case alpha
       # - any numeric
       & - any alphanumeric
       % - any punctuation
       ? - any printable character (including blank)
       ! - any printable character (except blank)
       ^ - any control character (0x00-0x1e & 0x7f-0xff)
       ; - any 1 of a blank, period, comma,or semicolon
       * - allow 0,1,or more of the preceding character
           (which may be a special character)
                  pattern match examples
                  ----------------------
 @#@ #@#         - Canadian postal code (allowing 1 blank in the middle)
 @#@ *#@#        - Canadian postal code
                   (allowing 0,1,or more blanks in the middle)
 ###-###-####   - a telephone#
 (###) ###-#### - a telephone# (alternate format)
 &*.tbl         - a filename (probably) with '.tbl' extension
                  ('&*' allows variable no of alphanumerics before the '.')
 !*.tbl         - note: this will not work because '!' is any non-blank
                - the '!*' would gobble up the entire word before the
                  '.tbl' could be detected
                - '&*.tbl' above works because the '.' stops the
                  alphanumeric string match

Goto:   Begin this document End this document UVSI Home-Page

C5. 2 table types for scan by table (scan2 & scan2d)

scan2tbl1 - sample table type 1

 # scan2tbl1 - table file for test/demo jobs pf/scan2, scan2d, etc
 # tbl type1 - qualifiers apply only to search pattern on current line of table
 # 01-30 - search pattern (ended by 1st tilde)
 # 31-60 - presence qualifier, must ALSO be present, disabled by tildes
 # 61-80 - absence qualifier, must NOT be present, disabled by tildes
 #
 Vancouver~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~604~~~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~(table end marker '~~' col 1&2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

scan2tbl2 - sample table type 2

 # scan2tbl2 - scan table for scan2, scan2d, etc (see SCANjobs.doc)
 # table type2 - search patterns & qualifiers INDEPENDENT of table line#
 #               matching recs - have a match to any entry in 01-30
 #               & a match to ANY entry in 31-60 (if any specified)
 #               & must NOT match ANY entry in 61-80 (if any specified)
 # 01-30 - search pattern (ended by 1st tilde & tilde filled to col 30)
 # 31-60 - qualifier 'also present' on same data line as search pattern match
 # 61-80 - qualifier 'not  present' on same data line as search pattern match
 #
 Vancouver~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~(table end marker '~~' col 1&2)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

notes

The best way to understand these concepts is to run scan2 & scan2d with the test/demo files provided (tf/names1, tf/names2, etc).

Please see the scan2 & scan2d operating instructions & demo results ahead.

Please see the demo files listed at the front of this section.

Goto:   Begin this document End this document UVSI Home-Page

D1. scan1 (run#1) - scan text file for any 1 pattern

scan1 will be run several times with different search patterns, qualifiers,& options. This 1st run will specify no arguments on the command line to cause prompts for all files & arguments, subsequent runs will specify the filename & arguments to inhibit the prompts.

operating instructions


 uvcopy scan1            - execute uvcopy to interpret prmfile 'scan1'
 ============
                    NOTE - no args on command line causes prompts below:
 uop=q1a1b99999c0d128   - option defaults
       a1               - begin scan at line #1 (default) of input file
       a0               - causes prompt for search pattern to BEGIN scan
         b99999         - end scan at line #99999 (dflt) of input file
         b0             - causes prompt for search pattern to END scan
               c0       - begin scan at col #1 (zero rel) of input lines
                 d128   - length of scan area default 128 bytes
                     p1 - 1 presence qual(31-60) & 1 absence qual(61-80)'
                     p2 - 2 presence quals(31-60)+(61-80) & NO absence quals'
 User OPtion (uop) defaults  = q1a1b99999c0d128
  null to accept or re-specify (1 or more) -->      <-- accept default uops
 tf/names1 = default fili1 - null accept or reenter ?
                                         -->        <-- accept dflt input
 enter your search pattern (max 64 bytes)
                                         --> Canada <-- enter search arg1
 enter qualifier present (null to disable)   ^^^^^^
                                         -->        <-- no presence qual
 enter qual2 absent, or present if option p2
                                         -->        <-- no absence qual
 match options: i=case-insensitive, p=patterns(@,#,etc)
 quote inhibits: q1=no scan within singles,q2=doubles,q3=both
 enter match options: i,p,q1/q2/q3,n,or null
                                         -->        <-- no match options
 EOF fili1 35 rds, 0 wrts, 5 hits, 470 size, fname=tf/names1
 EOF filo1 0 rds, 10 wrts, 5 hits, 428 size, fname=scan1.aud
 display/edit/print/none ? (cat/vi/uvlp/null)
                                         --> cat    <-- display report

sample report

 JOB: scan1  file: tf/names1  search: Canada  qualpresent:   absent:
  searchbgn:   searchend:   matchops:   userops: q1a1b99999c0d256p1
 ====================================================== 1998/07/25_11:37:27
 00004 Vancouver BC Canada
 00010 Victoria BC Canada
 00016 Toronto Canada
 00023 K1Y 2L6 Canada
 ====================================================== 1998/07/25_11:37:27
 EOF: 00004 matches in 00036 lines

Goto:   Begin this document End this document UVSI Home-Page

D2. scan1 (run#2) - scan a text file for any 1 pattern

This is the 2nd run of the 'scan1' test/demo's.

  1 - scan tf/names1 for 'Canada' with no qualifiers & no options (prior page)
 *2 - scan tf/names1 for 'Canada' qualified by 'BC' also present (this page)
  3 - scan tf/names1 for 'canada', no qualifiers, option 'i' case insensitive
  4 - scan for '@#@ *#@#' pattern to match any postal code (option p required)

The 1st run specified no arguments on the command line & we were prompted for all arguments. This & subsequent runs will specify significant arguments on the command line. You will be prompted for any unspecified arguments, but you can simply reply null to these.

Please see page C3 for the definition of all arguments for the SCANjobs.

operating instructions


 uvcopy scan1,fili1=tf/names1,arg1=Canada,arg2=BC
 ================================================
 display/edit/print/none ? (cat/vi/uvlp/null)
                                         --> cat    <-- display report

sample report

 JOB: scan1  file: tf/names1  search: Canada  qualpresent: BC  absent: ~
  scanbgn:   scanend:   matchops: n  userops: q1a1b99999c0d128q0
 ====================================================== 1995/11/21_09:22:26
 00004 Vancouver BC Canada
 00010 Victoria BC Canada
 ====================================================== 1995/11/21_09:22:26
 EOF: 00002 matches in 00035 lines

Please compare this audit report to the previous report & note that fewer lines are reported because the search pattern 'Canada' is now qualified by 'BC' also present on the same line.

Goto:   Begin this document End this document UVSI Home-Page

D3. scan1 (run#3) - scan a text file for any 1 pattern

This is the 3rd run of the 'scan1' test/demo's.

  1 - scan tf/names1 for 'Canada' with no qualifiers & no options
  2 - scan tf/names1 for 'Canada' qualified by 'BC' also present
 *3 - scan tf/names1 for 'canada', no qualifiers, option 'i' case insensitive
  4 - scan for '@#@ *#@#' pattern to match any postal code (option p required)

The 1st run specified no arguments on the command line & we were prompted for all arguments. This & subsequent runs will specify all arguments on the command line to avoid the prompts. Note that some arguments specify '~' tilde to inhibit the prompts.

Please see page C3 for the definition of all arguments for the SCANjobs.

operating instructions


 uvcopy scan1,fili1=tf/names1,arg1=canada
 ========================================

significant prompts

 match options: i=case-insensitive, p=patterns
                                     reply ---> i     <-- case insensitive
 display/edit/print/none ? (cat/vi/uvlp/null)
                                     reply ---> cat    <-- display report

sample report

 JOB: scan1  file: tf/names1  search: canada  qualpresent:   absent:
  searchbgn:   searchend:   matchops: i  userops: q1a1b99999c0d256p1
 ====================================================== 1998/07/25_11:57:13
 00004 Vancouver BC Canada
 00010 Victoria BC Canada
 00016 Toronto CANADA
 00023 K1Y 2L6 CANADA
 ====================================================== 1998/07/25_11:57:13
 EOF: 00004 matches in 00036 lines

Please compare this audit report to the previous reports & note that more lines are reported because of the case insensitive option 'i' (must specify search patterns in lower case eg: 'canada')

Goto:   Begin this document End this document UVSI Home-Page

D4. scan1 (run#4) - scan a text file for any 1 pattern

This is the 5th run of the 'scan1' test/demo's.

  1 - scan tf/names1 for 'Canada' with no qualifiers & no options
  2 - scan tf/names1 for 'Canada' qualified by 'BC' also present
  3 - scan tf/names1 for 'canada', no qualifiers, option 'i' case insensitive
 *4 - scan for '@#@ *#@#' pattern to match any postal code (option p required)

The 1st run specified no arguments on the command line & we were prompted for all arguments. This & subsequent runs will specify all arguments on the command line to avoid the prompts. Note that some arguments specify '~' tilde to inhibit the prompts.

Please see page C3 for the definition of all arguments for the SCANjobs.

operating instructions


 uvcopy scan1,fili1=tf/names1,arg1u=@#@_*#@#
 ===========================================

significant prompts

 match options: i=insensitive, p=patterns(@#*)
                                     reply ---> p     <-- pattern scans
 display/edit/print/none ? (cat/vi/uvlp/null)
                                     reply ---> cat    <-- display report

sample report

 JOB: scan1  file: tf/names1  search: @#@ *#@#  qualpresent:   absent:
  searchbgn:   searchend:   matchops: p  userops: q1a1b99999c0d256p1
 ====================================================== 1998/07/25_12:23:03
 00005 V5P 3V8
 00011 V1P 2G3
 00017 M5W 1E6
 00023 K1Y 2L6 CANADA
 ====================================================== 1998/07/25_12:23:03
 EOF: 00004 matches in 00036 lines
note
  • 'arg1u=@#@_*#@#' matches any CDN postal code: @=any alpha,#=any numeric,
    *=matches any no of preceding chars (for blanks in center of code)
  • 'u' option (of arg1u=) converts '_' to blank when stored by uvcopy
  • match option 'p' required for these match characters to be effective
  • see other match characters with the 'scn' instruction in uvcopy3.doc

Goto:   Begin this document End this document UVSI Home-Page

D5. scan1 (run#5) - scan a text file for any 1 pattern

using 'test100' demo file vs 'names1'

 *5 - scan tf/test100 for 'nine' with no qualifiers
  6 - scan tf/test100 for 'nine' with NOT-present qualifier of 'ninety'
  7 - scan tf/test100 for 'nine' beginning at line# 20 & ending at line# 90
  8 - scan tf/test100 for 'nine' beginning at column# 21 for length 10

operating instructions


 uvcopy scan1,fili1=tf/test100,arg1=nine
 =======================================

scan1.aud report

 JOB: scan1  file: tf/test100  search: nine  qualpresent: ~  absent: ~
  scanbgn:   scanend:   matchops: n  userops: q1a1b99999c0d128q0
 ====================================================== 1995/11/21_09:32:20
 00009 0009 tf/test100 nine
 00019 0019 tf/test100 nineteen
 00029 0029 tf/test100 twenty nine
 00039 0039 tf/test100 thirty nine
 00049 0049 tf/test100 forty nine
 00059 0059 tf/test100 fifty nine
 00069 0069 tf/test100 sixty nine
 00079 0079 tf/test100 seventy nine
 00089 0089 tf/test100 eighty nine
 00090 0090 tf/test100 ninety
 00091 0091 tf/test100 ninety one
 00092 0092 tf/test100 ninety two
 00093 0093 tf/test100 ninety three
 00094 0094 tf/test100 ninety four
 00095 0095 tf/test100 ninety five
 00096 0096 tf/test100 ninety six
 00097 0097 tf/test100 ninety seven
 00098 0098 tf/test100 ninety eight
 00099 0099 tf/test100 ninety nine
 ====================================================== 1995/11/21_09:32:20
 EOF: 00019 matches in 00100 lines
note
  • compare this report to the next page (specifies 'ninety' NOT present)

Goto:   Begin this document End this document UVSI Home-Page

D6. scan1 (run#6) - scan a text file for any 1 pattern

using 'test100' demo file vs 'names1'

  5 - scan tf/test100 for 'nine' with no qualifiers
 *6 - scan tf/test100 for 'nine' with NOT-present qualifier of 'ninety'
  7 - scan tf/test100 for 'nine' beginning at line# 20 & ending at line# 90
  8 - scan tf/test100 for 'nine' beginning at column# 21 for length 10

operating instructions


 uvcopy scan1,fili1=tf/test100,arg1=nine,arg2=~,arg3=ninety
 ==========================================================
                                                ^^^^^^^^^^^
                                             (qualifier NOT ninety)

scan1.aud report

 JOB: scan1  file: tf/test100  search: nine  qualpresent: ~  absent: ninety
  scanbgn:   scanend:   matchops: n  userops: q1a1b99999c0d128q0
 ====================================================== 1995/11/21_09:31:04
 00009 0009 tf/test100 nine
 00019 0019 tf/test100 nineteen
 00029 0029 tf/test100 twenty nine
 00039 0039 tf/test100 thirty nine
 00049 0049 tf/test100 forty nine
 00059 0059 tf/test100 fifty nine
 00069 0069 tf/test100 sixty nine
 00079 0079 tf/test100 seventy nine
 00089 0089 tf/test100 eighty nine
 ====================================================== 1995/11/21_09:31:04
 EOF: 00009 matches in 00100 lines
note
  • compare this report to the previous page (no qualifiers)

Goto:   Begin this document End this document UVSI Home-Page

D7. scan1 (run#7) - scan a text file for any 1 pattern

using 'test100' demo file vs 'names1'

  5 - scan tf/test100 for 'nine' with no qualifiers
  6 - scan tf/test100 for 'nine' with NOT-present qualifier of 'ninety'
 *7 - scan tf/test100 for 'nine' beginning at line# 20 & ending at line# 90
  8 - scan tf/test100 for 'nine' beginning at column# 21 for length 10
note
  • this run illustrates user options (uops) to restrict scanning by
    specify a beginning & ending line# within the file.

operating instructions


 uvcopy scan1,fili1=tf/test100,arg1=nine,uop=q0a20b90
 ====================================================
                                         ^^^^^^^^^^^^
                              (options for begin/end scan line#s a/b)

scan1.aud report

 JOB: scan1  file: tf/test100  search: nine  qualpresent: ~  absent: ~
  scanbgn:   scanend:   matchops: n  userops: q1a1b99999c0d128q0a20b90
 ====================================================== 1995/11/21_09:28:46
 00029 0029 tf/test100 twenty nine
 00039 0039 tf/test100 thirty nine
 00049 0049 tf/test100 forty nine
 00059 0059 tf/test100 fifty nine
 00069 0069 tf/test100 sixty nine
 00079 0079 tf/test100 seventy nine
 00089 0089 tf/test100 eighty nine
 ====================================================== 1995/11/21_09:28:46
 EOF: 00007 matches in 00090 lines
note
  • compare this report to the next page which will restrict scanning
    by column# vs line# as on this page.

Goto:   Begin this document End this document UVSI Home-Page

D8. scan1 (run#8) - scan a text file for any 1 pattern

using 'test100' demo file vs 'names1'

  5 - scan tf/test100 for 'nine' with no qualifiers
  6 - scan tf/test100 for 'nine' with NOT-present qualifier of 'ninety'
  7 - scan tf/test100 for 'nine' beginning at line# 20 & ending at line# 90
 *8 - scan tf/test100 for 'nine' beginning at column# 21 for length 10
note
  • this run illustrates user options (uops) to restrict scanning by
    specify a beginning & ending COLUMN# within each line of the file.

operating instructions


 uvcopy scan1,fili1=tf/test100,arg1=nine,uop=q0c20d10
 ====================================================
                                         ^^^^^^^^^^^^
                              (options for scan column# begin/end c/d)

scan1.aud report

 JOB: scan1  file: tf/test100  search: nine  qualpresent: ~  absent: ~
  scanbgn:   scanend:   matchops: n  userops: q1a1b99999c0d128q0c20d10
 ====================================================== 1995/11/21_09:29:39
 00029 0029 tf/test100 twenty nine
 00039 0039 tf/test100 thirty nine
 00049 0049 tf/test100 forty nine
 00059 0059 tf/test100 fifty nine
 00069 0069 tf/test100 sixty nine
 00079 0079 tf/test100 seventy nine
 00089 0089 tf/test100 eighty nine
 00099 0099 tf/test100 ninety nine
 ====================================================== 1995/11/21_09:29:40
 EOF: 00008 matches in 00100 lines
note
  • compare this report to the previous page which restricted scanning
    by line# vs column# as on this page.
  • you could of course restrict both line#s & column#s together.

Goto:   Begin this document End this document UVSI Home-Page

E1. scan1d - scan all files in a directory for any 1 pattern

The previous pages have presented several examples of using 'scan1' which is good for illustrations because it scans only 1 file, however 'scan1d' (this job) is MUCH MORE USEFUL because it scans entire directories.

The default input directory for scan1d is coded as the uvadm/tf directory which has about 100 files & some of these are binary which causes problems when expecting text; see explanation on the next page --->

operating instructions


 uvcopy scan1d      <-- will prompt for directory, patterns,& options
 =============
 uop=q1a1b99999c0d128p1 - option defaults
       a1               - begin scan at line #1 (default) of input file
       a0               - causes prompt for search pattern to BEGIN scan
         b99999         - end scan at line #99999 (dflt) of input file
         b0             - causes prompt for search pattern to END scan
               c0       - begin scan at col #1 (zero rel) of input lines
                 d128   - length of scan area default 128 bytes
                     p1 - 1 presence qual(31-60) & 1 absence qual(61-80)'
                     p2 - 2 presence quals(31-60)+(61-80) & NO absence quals'
 User OPtion (uop) defaults  = q1a1b99999c0d128
  null to accept or re-specify (1 or more) -->        <-- default options
 tf = default fild1 - null accept or reenter ?
                                           -->        <-- default indir tf
 enter your search pattern (max 64 bytes)
                                           --> Canada <-- search pattern
 enter qualifier present (null to disable)
                                           --> BC     <-- qualifier present
 enter qualifier absent,or 2nd present (optn p2)
                                           --> 0x2C   <-- qualifier absent
 match options: i=case-insensitive, p=patterns(@,#,etc)
 quote inhibits: q1=no scan within singles,q2=doubles,q3=both
 enter match options: i,p,q1/q2/q3,n,or null
                                           -->        <-- no match options

console displays

 EOF fili1 9 rds, 0 wrts, 0 hits, 410 size, fname=tf/HP10cpi
 EOF fili1 5 rds, 0 wrts, 1 hits, 107 size, fname=tf/OTadrs
              - - - etc - - -
  rcsz full w/o LF, null=try next, e=EOF, [E=EOD] ?   tf/PDF.DBF   <--NOTE
  loopf get.. fili1,a0(1024)
 EOF fili1 2 rds, 0 wrts, 0 hits, 2000 size, fname=tf/PDF.DBF
              - - - etc - - -
 EOF fili1 5 rds, 0 wrts, 1 hits, 135 size, fname=tf/UVadrs
 EOF filo1 0 rds, 20 wrts, 8 hits, 1593 size, fname=scan1d.aud
 EOF fild1 98 rds, 0 wrts, 8 hits, 1584 size, fname=tf
NOTE
  • see explanation on the next page --->

Goto:   Begin this document End this document UVSI Home-Page

E1a. scan1d - scan all files in a directory for any 1 pattern

note re: binary file problem

You will get several warning messages that are caused by binary or EBCDIC files that do not have LineFeeds.


 rcsz full w/o LF, null=try next, e=EOF, [E=EOD] ?   tf/PDF.DBF   <--NOTE
 ==============================================================

You have 3 choices:

1 - keep hitting return until you get by them 2 - enter 'e' to end that file & continue to next 3 - enter 'E' to end the directory (& the job) prematurely

We can avoid the above problems by setting up a temporary directory & copying a few files to it & then running scan1d specifying our input as the temporary directory.


 mkdir tmp1                    - make a temporary directory
 ==========

 cp names1 names2 names3 tmp1  - copy 3 files to the tmp1 directory
 ============================

The following demos of scan1d will specify their input directory as 'tmp1' to avoid the binary file problem & also to provide a more easily verifiable test/demo situation.

Goto:   Begin this document End this document UVSI Home-Page

E2. scan1d - scan all files in a directory for any 1 pattern

This is a very powerful job which can scan directories containing hundreds of files, but to provide a more easily verifiable test situation, the previous page has instructed you to setup the 'tmp1' directory & copy 3 files into it from the uvadm/tf directory (names1,names2,names3).

scan1d - demo run #1

The following demo will scan 'tmp1' directory for lines including 'Canada', also 'BC', but NOT a comma ','. The comma must be coded in hex (0x2C) if entered on the command line.

scan1d demo operating instructions


 uvcopy scan1d,fild1=tmp1,arg1=Canada,arg2=BC,arg3=0x2C
 ======================================================
                               ^^^^^^      ^^      ^^^^

audit report - scan1d demo

 JOB: scan1d  dir: tmp1  search: Canada  qualpresent: BC  absent: ,
  scanbgn:   scanend:   matchops:    userops: q1a1b99999c0d128
 ====================================================== 1995/11/21_11:57:08
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00035                             2 hits @EOF: tmp1/names1
 00001 Owen Townsend;UV Software;5436 Victoria Dr;Vancouver BC Canada;V5P 3V8 604-321-1024
 00003 Pavel Bure;(the Russian Rocket);GM Place;Vancouver BC Canada;V4V 1X1
 00006                             2 hits @EOF: tmp1/names3
 ====================================================== 1995/11/21_11:57:08
  EOD: 00004 hits in 0002 files of 0003 total (00047 lines)

'EOF' stats are shown at the end of each file 'only' if at least 1 match occurred in that file (saves clutter when hit rate is low) the 'EOD' stats tells you how many files had matches of the total files in the directory

This job is very useful when making changes that could affect several files. Run this job using a relevant keyword(s) to find all the files and line#'s that may require changes. Print the audit report & use it as your guide when making changes with vi. (see REPjobs.doc for automated changes).

--> Try this job on 1 of your directories of programs or text files, specifying whatever search patterns & qualifiers make sense to you.

Goto:   Begin this document End this document UVSI Home-Page

E2a. scan1d - scan all files in a directory for any 1 pattern

scan1d (run#2) - scan COBOL programs for 'UPSI'

UPSI is User Program Switch Indicators, and this feature requires special considerations when converting cobol programs from a mainframe to a UNIX system (probably to Micro Focus cobol).

demo operating instructions


 uvcopy scan1d,fild1=bat1,arg1=UPSI
 ==================================

audit report

 JOB: scan1d  dir: bat1  search: UPSI  qualpresent: ~  absent: ~
  scanbgn:   scanend:   matchops:    userops: q1a1b99999c0d128
 ====================================================== 1995/11/14_11:25:51
 00016 000016     SYSSWCH-1 IS UPSI-1
 00017 000017     SYSSWCH-2 IS UPSI-2
 00149                             2 hits @EOF: bat1/cobol1.bat
 00015 000015 SYSSWCH1 IS UPSI1, ON STATUS IS PAGEHDNGS.
 00109 000109     IF UPSI1-ON READY TRACE.
 00158                             2 hits @EOF: bat1/cobol6.bat
 00015 000015         SYSSWCH1 IS UPSI1
 00166 000161        DISPLAY '1' UPON UPSI1
 00190                             2 hits @EOF: bat1/cobol7.bat
 00017 000017     SYSSWCH-1 ON STATUS IS UPSI1-ON
 00018 000018     SYSSWCH-2 ON STATUS IS UPSI2-ON
 00160                             2 hits @EOF: bat1/cobol8.bat
 ====================================================== 1995/11/14_11:26:00
  EOD: 00036 hits in 0007 files of 0013 total (01563 lines)

notes

Actually this job would not be very useful if the cobol program had not defined the username for UPSI to include the 'UPSI' pattern. (SPECIAL NAMES could have assigned any name to the UPSI switches)

The Vancouver Utilities provides a special job to solve this problem (please see the 'chkupsi2' job described in COBcheck.doc ).

chkupsi2 is a special purpose job (vs the scan1d general purpose job) which tables the user defined names from the SPECIAL NAMES clause & then searches the procedure division for 'DISPLAY UPON' these names.

Goto:   Begin this document End this document UVSI Home-Page

F1. scan2 (run#1) scan for matches to a table of search patterns

Illustrates
  • matching with table type #1
 *F1 - scan tf/names1 for matches to tf/scantbl1 (table type #1)
  F2 - scan tf/names1 for matches to tf/scantbl2 (table type #2)
  F3 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'p')
  F4 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'i')

operating instructions


 uvcopy scan2       <-- would solicit filenames, patterns,& options
 ============
note
  • the following demo will scan a text file (tf/names1) for any match to
    a table of patterns (tf/scan2tbl1) & create a report of matching lines.

 uvcopy scan2,fili1=tf/names1,fili2=tf/scan2tbl1,uop=t1
 ======================================================
                                       ^^^^^^^^^     ^^

audit file report

 JOB: scan2  file: tf/names1  matchops: dg  userops: q1a1b99999c0d128t1
 table-file: tf/scan2tbl1  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:07:20
 Vancouver~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~604~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~(table end marker minimum '~~' cols 1&2)~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:07:20
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00022 Toronto ON CANADA
 00028 Toronto, ON
 ====================================================== 1995/11/21_10:07:21
  EOF 00004 matches on 00035 lines

The table file is 1st copied into the audit file for a complete record of search conditions. Each search pattern is terminated by the 1st tilde & patterns are tilde filled to show the max length allowed.

Table entries are 80 bytes allowing 1-30 for the search pattern, 31-60 for the present qualifier,& 61-80 for the not present qualifier.

Please confirm these matches by examining the complete test file tf/names1 which was listed previously on page B1 of this section.

Goto:   Begin this document End this document UVSI Home-Page

F2. scan2 (run#2) - scan for any match to a table of search patterns

Illustrates
  • matching with table type #2

table columns of patterns & qualifiers are independent (like 3 separate tables) any match from column 1 search pattern, and any match from column 2 qualifier present (if any coded) and NO match from column 3 qualifier absent, or 2nd present if option p2

  F1 - scan tf/names1 for matches to tf/scantbl1 (table type #1)
 *F2 - scan tf/names1 for matches to tf/scantbl2 (table type #2)
  F3 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'p')
  F4 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'i')

demo operating instructions


 uvcopy scan2,fili1=tf/names1,fili2=tf/scan2tbl2,uop=q0t2
 ========================================================
                                       ^^^^^^^^^       ^^

audit file report

 JOB: scan2  file: tf/names1  matchops: ndg  userops: q1a1b99999c0d128t1q0t2
 table-file: tf/scan2tbl2  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:09:03
 Vancouver~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:09:03
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00022 Toronto ON CANADA
 ====================================================== 1995/11/21_10:09:03
  EOF 00003 matches on 00035 lines

Please confirm these matches by examining the complete test file tf/names1 which was listed previously on page B1 of this section.

Also compare the command above to the command on the previous page & note that we have changed the table name (from tf/scan2tbl1 to tf/scan2tbl2) & specified table type #2 (via uop=q0t2 vs default of uop=q0t1).

Goto:   Begin this document End this document UVSI Home-Page

F3. scan2 (run#3) - scan for any match to a table of search patterns

Illustrates
  • match option 'p' (pattern match characters)
  • note the '@#@ *#@#' table entry
  F1 - scan tf/names1 for matches to tf/scantbl1 (table type #1)
  F2 - scan tf/names1 for matches to tf/scantbl2 (table type #2)
 *F3 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'p')
  F4 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'i')

operating instructions


 uvcopy scan2,fili1=tf/names1,fili2=tf/scan2tbl1,arg8=p
 ======================================================
                                                 ^^^^^^

audit file output

 JOB: scan2  file: tf/names1  matchops: pdg  userops: q1a1b99999c0d128t1q0t1
 table-file: tf/scan2tbl1  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:09:38
 Vancouver~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~604~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~(table end marker minimum '~~' cols 1&2)~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:09:38
 00004 Vancouver BC Canada
 00005 V5P 3V8 604-321-1024
 00011 V5P  3V8 604-321-5822
 00016 Vancouver BC Canada
 00017 V4V 1X1
 00022 Toronto ON CANADA
 00023 L4Z 2G6
 00028 Toronto, ON
 00029 Canada M2J 4Z7
 00035 ON K1Y 2L6
 ====================================================== 1995/11/21_10:09:38
  EOF 00010 matches on 00035 lines

Compare these results to scan2 run #1 (2 pages back) - the only difference is the 'p' option was selected on run #2 which activates special pattern match characters in the table.

Thus the '@#@ *#@#' table entry is now active and matches any Canadian postal codes in the file.

Goto:   Begin this document End this document UVSI Home-Page

F4. scan2 (run#4) - scan for any match to a table of search patterns

Illustrates
  • match option 'i' (case insensitivity)
  F1 - scan tf/names1 for matches to tf/scantbl1 (table type #1)
  F2 - scan tf/names1 for matches to tf/scantbl2 (table type #2)
  F3 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'p')
 *F4 - scan tf/names1 for matches to tf/scantbl1 (type #1 & match option 'i')

operating instructions


 uvcopy scan2,fili1=tf/names1,fili2=tf/scan2tbl1,arg8=i
 ======================================================
                                                 ^^^^^^

audit file output

 JOB: scan2  file: tf/names1  matchops: idg  userops: q1a1b99999c0d128t1q0t1
 table-file: tf/scan2tbl1  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:10:17
 vancouver~~~~~~~~~~~~~~~~~~~~~bc~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 toronto~~~~~~~~~~~~~~~~~~~~~~~on~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ottawa~~~~~~~~~~~~~~~~~~~~~~~~canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 v5p 3v8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~604~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~~(table end marker minimum '~~' cols 1&2)~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:10:17
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00022 Toronto ON CANADA
 00028 Toronto, ON
 00034 Ottawa, CANADA
 ====================================================== 1995/11/21_10:10:17
  EOF 00005 matches on 00035 lines

Compare these results to scan2 run #1 (3 pages back) - the only difference is the 'i' match option selected here on run #3 for case insensitivity.

We now get more matches because CANADA matches as well as Canada.

Note that the entire table has been translated to lower case as are the data records before matching to the table.

Goto:   Begin this document End this document UVSI Home-Page

G1. scan2d (run#1) scan for matches to table of patterns (type1)

This is a very powerful job which can scan directories containing hundreds of files, but to provide a more easily verifiable test situation, page 'E0a' has instructed you to setup the 'tmp1' directory & copy 3 files into it from the uvadm/tf directory (names1,names2,names3).

*G1 - scan all files in a directory using a type 1 table G2 - scan all files in a directory using a type 2 table

demo operating instructions


 uvcopy scan2d,fild1=tmp1,fili2=tf/scan2tbl1,uop=t1
 ==================================================
                                   ^^^^^^^^^     ^^

audit report - scan2d run#2

 JOB: scan2d  dir: tmp1  matchops: ndg  userops: q1a1b99999c0d128t1
 table-file: tf/scan2tbl1  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:24:19
 Vancouver~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~604~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:24:19
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00022 Toronto ON CANADA
 00028 Toronto, ON
 00035                             4 hits @EOF: tmp1/names1
 00004 "S. Allinson","Allinson-Ross","4250 Sherwoodtowne Blvd.","Toronto ON CANADA","L4Z 2G6"
 00005 "R. Dainty","Unisys Canada Inc.","2001 Sheppard Ave E","Toronto, ON","Canada M2J 4Z7"
 00006                             2 hits @EOF: tmp1/names2
 00001 Owen Townsend;UV Software;5436 Victoria Dr;Vancouver BC Canada;V5P 3V8 604-321-1024
 00003 Pavel Bure;(the Russian Rocket);GM Place;Vancouver BC Canada;V4V 1X1
 00004 S. Allinson;Allinson-Ross;4250 Sherwoodtowne Blvd.;Toronto ON CANADA;L4Z 2G6
 00005 R. Dainty;Unisys Canada Inc.;2001 Sheppard Ave E;Toronto, ON Canada M2J 4Z7
 00006                             4 hits @EOF: tmp1/names3
 ====================================================== 1995/11/21_10:24:19
  EOD: 00010 hits in 0003 files of 0003 total (00047 lines)

Table type1 means that the qualifiers (present & absent) apply only to the search pattern on that line of the table. Please see the detailed explanation on page 'C5'.

Goto:   Begin this document End this document UVSI Home-Page

G2. scan2d (run#2) scan for matches to a table of patterns (type2)

The input to the 'scan2d' demos is the 'tmp1' directory which has been populated with 3 files (names1,names2,names3) as previously described.

G1 - scan all files in a directory using a type 1 table *G2 - scan all files in a directory using a type 2 table


 uvcopy scan2d,fild1=tf,fili2=tf/scan2tbl2,uop=t2
 ================================================
                                 ^^^^^^^^^     ^^

audit report - scan2d run#3

 JOB: scan2d  dir: tmp1  matchops: ndg  userops: q1a1b99999c0d128t1q0t2
 table-file: tf/scan2tbl2  scanbgn:   scanend:
 ====================================================== 1995/11/21_10:23:38
 Vancouver~~~~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~~~~~~~~~~~,~~~~~~~~~~~~~~~~~
 Toronto~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Ottawa~~~~~~~~~~~~~~~~~~~~~~~~Canada~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 V5P 3V8~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 @#@ *#@#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 ====================================================== 1995/11/21_10:23:38
 00004 Vancouver BC Canada
 00016 Vancouver BC Canada
 00022 Toronto ON CANADA
 00035                             3 hits @EOF: tmp1/names1
 00001 Owen Townsend;UV Software;5436 Victoria Dr;Vancouver BC Canada;V5P 3V8 604-321-1024
 00003 Pavel Bure;(the Russian Rocket);GM Place;Vancouver BC Canada;V4V 1X1
 00004 S. Allinson;Allinson-Ross;4250 Sherwoodtowne Blvd.;Toronto ON CANADA;L4Z 2G6
 00006                             3 hits @EOF: tmp1/names3
 ====================================================== 1995/11/21_10:23:38
  EOD: 00006 hits in 0002 files of 0003 total (00047 lines)

This command is the same (as the previous page) except it specifies a type 2 table (uop=t2) whose name is tf/scan2tbl2 vs tf/scan2tbl1.

In table type1 the qualifiers apply only to the search pattern on that line of the table.

In table type2 the qualifiers are independent (like separate tables), there must be a match from column 1,& 2, but not 3. Please see the detailed explanation of table types on page 'C5'.

Goto:   Begin this document End this document UVSI Home-Page

H1. scan3d - scan directory selecting records between any 2 patterns

Scan3d is a pre-programmed job which will scan a directory of text files and create a report including the text lines between any 2 specified patterns, optionally qualified by a 3rd pattern which must be or must not be found between the lines containing the 1st 2 patterns.

Suppose you wanted to review all the Indexed file 'select' statements in your cobol source library.

This example will extract the lines between 'FILE-CONTROL' & 'DATA DIV' from all programs in your source directory, but only if at least 1 file is 'INDEXED'.

                     ** operating instructions **
 command / prompts                                   suggested responses
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 uvcopy scan3d                          <-- execute uvcopy & prmfile scan3d
 =============
uop=q1m15
  • option defaults
  • max lines to search for end pattern
    ---> null accept default options
 bat1 = default directory - accept/change? --->   null entry to accept
 enter select start pattern  ------------------>  FILE-CONTROL
 enter select stop  pattern  ------------------>  DATA DIV
 qualifier pattern =present !not present ------>  =INDEXED
 enter pattern match option (p/i/n) ?    ------>  n   (not required)
 report: display/edit/print/none ? (enter: cat/vi/lp/null)
                                             -->  vi  <-- examine report
note1
  • please see the audit file contents listed on the next page
note2
  • For a good example of using the qualifier 3rd pattern, please
    see JCLcheck.doc where this job is used to find
    OS/3 SORT's with missing RCSZ parameters.

Goto:   Begin this document End this document UVSI Home-Page

H2. scan3d - scan directory selecting records between any 2 patterns

scan3d - sample report

 JOB=scan3d   scan files in dir: bat1
  - selecting from "FILE-CONTROL" to "DATA DIV" qualified by "=INDEXED"
 ------------------------------------------------------ 1995/11/15_08:00:31
 00018 000018 FILE-CONTROL.                                                    CO
 00019 000019     SELECT CUSMAS ASSIGN TO DISC-CUSMAS-F                        CO
 00020 000020                   ORGANIZATION IS INDEXED                        CO
 00021 000021                   RECORD KEY IS CM-NUMBER                        CO
 00022 000022         ALTERNATE RECORD KEY IS CM-ADDRESS-2 WITH DUPLICATES     CO
 00023 000023                   ACCESS MODE IS SEQUENTIAL                      CO
 00024 000024                   FILE STATUS IS CUSMAS-STATUS.                  CO
 00025 000025     SELECT CUSLIST ASSIGN TO PRINTER-CUSLIST-F.                  CO
 00026 000027 DATA DIVISION.                                                   CO
                            10 selected from   149 @EOF: bat1/cobol3.bat
 00019 000019 FILE-CONTROL.                                                    CO
 00020 000020     SELECT CUSMAS  ASSIGN TO DISC-CUSMAS-F                       CO
 00021 000021                    ORGANIZATION IS SEQUENTIAL                    CO
 00022 000022                    ACCESS MODE IS SEQUENTIAL                     CO
 00023 000023                    FILE STATUS IS CUSMAS-STATUS.                 CO
 00024 000024     SELECT CUSMAS2 ASSIGN TO DISC-CUSMAS2-F                      CO
 00025 000025                    ORGANIZATION IS INDEXED                       CO
 00026 000026                    ACCESS MODE IS SEQUENTIAL                     CO
 00027 000027                    RECORD KEY IS CM2-ADDRESS-2                   CO
 00028 000028                    FILE STATUS IS CUSMAS2-STATUS.                CO
 00029 000029     SELECT CUSLIST ASSIGN TO PRINTER-CUSLIST-F.                  CO
 00030 000031 DATA DIVISION.                                                   CO
                            13 selected from   147 @EOF: bat1/cobol4.bat
 00017 000017 FILE-CONTROL.                                                    CO
 00018 000018     SELECT DISC-MAS ASSIGN TO DISC-CUSMAS-F                      CO
 00019 000019                   ORGANIZATION IS INDEXED                        CO
 00020 000020                   ACCESS MODE IS DYNAMIC                         CO
 00021 000021                   RECORD KEY IS CM-NUMBER                        CO
 00022 000022                   ALTERNATE RECORD KEY IS CM-ADDRESS-2           CO
 00023 000023                   WITH DUPLICATES                                CO
 00024 000024                   FILE STATUS IS CUSMAS-STATUS.                  CO
 00025 000025     SELECT CUSLIST ASSIGN TO PRINTER-CUSLIST-F.                  CO
 00026 000031 DATA DIVISION.                                                   CO
                            15 selected from   158 @EOF: bat1/cobol6.bat
 ------------------------------------------------------ 1995/11/15_08:00:38
  EOD: 00031 selects in 0003 files of 0013 total (01563 lines)

Goto:   Begin this document End this document UVSI Home-Page

I1. count1d - scan directory for lines with spcfd patterns & counts

count1d scans all files in a directory & reports lines that contain specified patterns and specified occurrences of those patterns <=!> specified counts. Here is the command syntax, followed by some examples.


 uvcopy 'count1d,fild1=<input-directory>,filo1=<output-file>\
 ============================================================
                ,arg1=<argument#1>,arg2=<argument#2>,arg3=<argument#3>'
                =======================================================
fild1
  • specifies the directory containing the files to be scanned
    this routine will read all the files in this directory.
filo1
  • specifies the output report filename (default count1d.rpt)
arg1
  • contains <pattern><compare><count><and/or>
    where <pattern> is the pattern string to scan for
    <compare> is one of: '<', '=', '!', '>'
    <count> is a number
    <and/or> may be: '&', '|', or absent (default '&')
arg2 & arg3
  • similar to arg1

examples: 'arg1=Vancouver=1,arg2=Canada>0,Ottawa<1'

           'arg1=Vancouver>0|,arg2=Toronto>0|,Ottawa>0'
           'arg1=Canada>0&,arg2=Vancouver>0|,Toronto>0'

NOTE: single quote marks are required to protect the < or > from the shell.

count1d reads the input file and scan each line for the patterns of the three arguments, counting the occurrences of each. If the counts agree with the requested counts, the data line is reported with its line# in the file. At the end of each file, the total matches and more importantly the filename are reported, but only if there was at least 1 match in that file.

Unused arguments may be left blank. Any unspecified arguments will be prompted for when the program is run.

count1d sample command line


 uvcopy 'count1d,fild1=tmp1,arg1=Vancouver=1,arg2=Canada>0,Ottawa<1'
 ==================================================================

This would find all lines in all files of the tmp1 directory containing 1 occurrence of 'Vancouver', 1 or more occurrences of 'Canada', and less than 1 occurrence of 'Ottawa'.

See this demo & the generated report file on the next page --->

Goto:   Begin this document End this document UVSI Home-Page

I2. count1d - scan directory for lines with spcfd patterns & counts

GIVEN
  • directory tmp1 containing test files name1, name2, name3
    (copied from /home/uvadm/tf - see listings on page 'B1')
REQUIRED
  • list lines with 1 'Vancouver', 1 or more 'Canada's,
    but no semicolons

 uvcopy 'count1d,fild1=tmp1,arg1=Vancouver=1,arg2=Canada>0,arg3=;<1'
 ==================================================================

demo console output

 count1d - scan directory & report lines with specified counts of 3 patterns
 uop=q1c1 - option defaults
       c1 - case insensitive (applies to all 3 patterns)
       c0 - case sensetive
 User OPtion (uop) defaults  = q1c1
  null to accept or re-specify (1 or more) -->     <-- accept default options

EOF fili1 36 rds, 0 wrts, 1 hits, 447 size, fname=tmp1/names1 EOF fili1 6 rds, 0 wrts, 0 hits, 440 size, fname=tmp1/names2 EOF fili1 6 rds, 0 wrts, 1 hits, 499 size, fname=tmp1/names3 EOF filo1 0 rds, 14 wrts, 0 hits, 594 size, fname=count1d.rpt EOF fild1 5 rds, 0 wrts, 2 hits, 80 size, fname=tmp1 display/edit/print/none ? (more/vi/uvlp/null) --> cat <-- display report

demo report output

 count1d - scan a directory & report lines with specified counts of 3 patterns
 Directory: tmp1  Date: 1998/07/25_11:10:06  Options: q1c1
 arg1: Vancouver=1
 arg2: canada>0
 arg3: ;<1
 =======================================================================
 00004 Vancouver BC Canada
 00036             0001 matches in: tmp1/names1
 00001 "Owen Townsend","UV Software","5436 Victoria Dr","Vancouver BC Canada","V5P 3V8"
 00006             0001 matches in: tmp1/names3
 =======================================================================
 Total files=0001  matched files=0003  directory=tmp1/names3

Goto:   Begin this document End this document UVSI Home-Page

J1. count1d - scan directory for FILES with spcfd patterns & counts

count2d will report the names of files that contain specified patterns and specified occurrences of those patterns <=!> specified counts. Here is the command syntax, followed by some examples.


 uvcopy 'count2d,fild1=<input-directory>,filo1=<output-file>\
 ============================================================
                ,arg1=<argument#1>,arg2=<argument#2>,arg3=<argument#3>'
                =======================================================
fild1
  • specifies the directory containing the files to be scanned
    this routine will read all the files in this directory.
filo1
  • specifies the output report filename (default count2d.rpt)
arg1
  • contains <pattern><compare><count><and/or>
    where <pattern> is the pattern string to scan for
    <compare> is one of: '<', '=', '!', '>'
    <count> is a number
    <and/or> may be: '&', '|', or absent (default '&')
arg2 & arg3
  • similar to arg1

examples: 'arg1=Toronto=1,arg2=Vancouver>2,Ottawa<3'

           'arg1=Toronto>0|,arg2=Vancouver>0|,Ottawa>0'
           'arg1=Canada>0&,arg2=Vancouver>0|,Toronto>0'

NOTE: single quote marks are required to protect the < or > from the shell.

count2d reads the input file and scans for the patterns of the three arguments, counting the occurrences of each. If the counts agree with the requested counts, the filename is printed; otherwise it is ignored.

Unused arguments may be left blank. Any unspecified arguments will be prompted for when the program is run.

This job reports only the filenames of the matching files. It does not report any data lines as do most of the other UV SCANjobs. Another important difference is that the patterns may be anywhere in the file, not necessarily on the same line (as for many other jobs).

count2d sample command line


 uvcopy 'count2d,fild1=bat1,arg1=program-id>0,arg2u=file_section<1'
 ==================================================================

This would find all files in directory bat1 containing 1 or more occurrences of 'program-id', but with no occurrences of 'file section' See this demo & the generated report file on the next page --->

Goto:   Begin this document End this document UVSI Home-Page

J2. count1d - scan directory for FILES with spcfd patterns & counts

GIVEN
  • directory of source programs /home/uvadm/bat1
REQUIRED
  • find names of COBOL programs that have no 'FILE SECTION'

 uvcopy 'count2d,fild1=bat1,arg1=program-id>0,arg2u=file_section<1'
 ==================================================================
notes
  • arg1=program-id>0 restricts consideration to COBOL programs
  • arg2u=file_section<1 specifies that 'file section' not found
  • option 'u' of 'arg2u' converts underscores of 'file_section'
    to blanks when stored for search (blanks not allowed on cmd line)
  • OR you can omit arg1/arg2 from cmd line & enter them at the prompts

demo console output

 uop=q1c1 - option defaults
       c1 - case insensitive (applies to all 3 patterns)
       c0 - case sensetive
 User OPtion (uop) defaults  = q1c1
 null to accept or re-specify (1 or more) -->       <-- accept defaults
 enter arg3: pattern<=!>count (null disable)-->      <-- null (arg3 n/r)
 EOF fili1 149 rds, 0 wrts, 0 hits, 11771 size, fname=bat1/cobol1.bat
 EOF fili1 147 rds, 0 wrts, 0 hits, 11613 size, fname=bat1/cobol2.bat
           - - - etc - - -
 EOF fili1 23 rds, 0 wrts, 1 hits, 857 size, fname=bat1/cobold.bat
 EOF fili1 21 rds, 0 wrts, 1 hits, 804 size, fname=bat1/cobole.bat
           - - - etc - - -
 EOF fili1 53 rds, 0 wrts, 0 hits, 2218 size, fname=bat1/cobolx.bat
 EOF filo1 0 rds, 9 wrts, 0 hits, 441 size, fname=count2d.aud
 EOF fild1 22 rds, 0 wrts, 2 hits, 352 size, fname=bat1
 display/edit/print/none ? (more/vi/uvlp/null) --> cat  <-- display results

demo report output

 count2d  Directory: bat1  Date: 1998/07/22_16:04:58  Options: q1c1
 arg1: program-id>0
 arg2: file section<1
 arg3:
 =======================================================================
 lines=00023 arg1=0001 arg2=0000 arg3=0000 file=bat1/cobold.bat
 lines=00021 arg1=0001 arg2=0000 arg3=0000 file=bat1/cobole.bat
 =======================================================================
 Total files=0020  matches=0002  directory=bat1/cobolx.bat

Goto:   Begin this document End this document UVSI Home-Page

J3. count1d - scan directory for FILES with spcfd patterns & counts

GIVEN
  • demo directory of OS3 job control (/home/uvadm/jcl1)
REQUIRED
  • find jobs that contain: UPSI, COMREG,& CONTROL-STREAM

 uvcopy 'count2d,fild1=jcl1,arg1=UPSI>0,arg2=COMREG>0,arg3=/$>0'
 ===============================================================
notes
  • 'UPSI','COMREG',& '/$' must be present to report the filename
    ('>0' specifies the count must be greater than 0)
  • command line enclosed in quotes to hide the '>' from the shell
  • alternatively you can omit the arg1,2,3 from the command line &
    wait for the prompts to enter the patterns,conditions,& counts.

 uvcopy count2d,fild1=jcl1
 =========================

demo console output

 uop=q1c1 - option defaults
       c1 - case insensitive (applies to all 3 patterns)
       c0 - case sensetive
 User OPtion (uop) defaults  = q1c1
 null to accept or re-specify (1 or more) -->       <-- accept default
 display/edit/print/none ? (cat/vi/uvlp/null)--> cat <-- display report

demo report output

 count2d  Directory: jcl1  Date: 1998/07/22_16:31:00  Options: q1c1
 arg1: UPSI>0
 arg2: COMREG>0
 arg3: /$>0
 =======================================================================
 lines=00065 arg1=0001 arg2=0001 arg3=0005 file=jcl1/jcltst2
 lines=00062 arg1=0001 arg2=0001 arg3=0005 file=jcl1/jcltst2a
 =======================================================================
 Total files=0039  matches=0002  directory=jcl1/uv3copy1

Goto:   Begin this document End this document UVSI Home-Page

K1. scan1t - scan for 1 pattern & 2 qualifiers within line# ranges

This job is quite different than other scan jobs in this section. The entire file is tabled in memory (allowing 20,000 lines of 100 bytes each).

The primary search pattern may be qualified by a line# range & 2 qualifying patterns may be specified by line# range - absolute or -/+ from the found search pattern.

command format

 uvcopy scan1t,fili1=inputfile,filo1=reportfile\
        ,arg1=searchpattern:searchfrom:searchto:reportfrom:reportto:options
        ,arg2=qualifier#1pattern:searchfrom:searchto:options
        ,arg3=qualifier2#pattern:searchfrom:searchto:options

sample command


 uvcopy scan1t,fili1=tf/test100,filo1=scan1t.tmp\
 ================================================
              ,arg1=seven:10:90:-1:+1,arg2=sixt:-1:-0,arg3=eight:+0:+1
              ========================================================
fili1
  • specifies the input filename
filo1
  • specifies the output filename (report)
arg1
  • searchpattern:searchfrom:searchto:reportfrom:reportto:options
    searchpattern
    searchfrom - line# to start search (default 0, may omit ::)
    searchto - line# to stop search (default 999999, may omit ::)
    reportfrom - line# relative to found search pattern (dflt -1)
    reportto - line# relative to found search pattern (dflt +1)
    options - options for search instruction (see 'sts' in uvcopy3.doc)
    'q3' inhibits matches within quotes
    'p' for pattern match chars (@=any alpha,#=any numeric)
arg2
  • qualifier#1pattern:searchfrom:searchto:options
    qual1pattern - may prefix with '!' for NOT present (vs present)
    searchfrom - line# start qualifier1 search (default 0)
    - may specify relative to found searchpattern - or +
    searchto - line# stop qualifier1 search (default 999999)
    - may specify relative to found searchpattern + or -
    options - options for search instruction (see 'sts' in uvcopy3.doc)
arg3
  • qualifier#2pattern:searchfrom:searchto:options
  • similar to arg2 above

Please see the results of the above sample on the next page --->

Goto:   Begin this document End this document UVSI Home-Page

K1a. scan1t - scan 1 file for 1 pattern & 2 qualifiers within line# ranges

See the command format explained on the previous page. The command below is shown on 2 lines using the '\' to indicate continuation, but it is better to key it all on 1 line (so you can use the KORN shell history).

demo operating instructions


 uvcopy scan1t,fili1=tf/test100,filo1=scan1t.tmp\
 ================================================
              ,arg1=seven:10:90:-1:+1,arg2=sixt:-1:-0,arg3=eight:+0:+1
              ========================================================

demo report file

 JOB: scan1t   FILE: tf/test100   DATE: 1997/04/01_11:24:37
 SEARCH PATTERN: seven:10:90:-1:+1
 QUALIFIER #1:   sixt:-1:-0
 QUALIFIER #2:   eight:+0:+1
 =======================================================================
 0016 0016 tf/test100 sixteen
 0017 0017 tf/test100 seventeen
 0018 0018 tf/test100 eightteen
 0066 0066 tf/test100 sixty six
 0067 0067 tf/test100 sixty seven
 0068 0068 tf/test100 sixty eight

 0100   Total   0002 matches found in file: tf/test100
 =======================================================================

Please see the tf/test100 demo file listed at the front of this section & try out various combinations of line# ranges & qualifier patterns & ranges.

 defaults --->  arg1 = search:0:9999999:-1:+1
                arg2 = qualifier1:0:9999999   <-- absolute values (no -/+)
                arg3 = qualifier2:0:9999999
 demo above-->  arg1 = seven:10:90:-1:+1
                arg2 = sixt:-1:-0             <-- relative to arg1 match -/+
                arg3 = eight:+0:+1

Goto:   Begin this document End this document UVSI Home-Page

K2. scan1td - scan directory for 1 pattern & 2 qualifiers in ranges

This job 'scan1td' is much more useful (than 'scan1t' on previous page) because it scans an entire directory of files (rather than 1 file at a time).

Try the following demo which scans about 20 COBOL programs in uvadm/bat1. We are searching for all references to 'UPSI' with 'DISPLAY' on the same or previous line & with SYSSWCH within 1st 50 lines (absolute).

demo to scan entire directory


 uvcopy scan1td,fild1=bat1,filo1=scan1td.tmp,arg1=UPSI:::-1:+1\
 ==============================================================
                           ,arg2=DISPLAY:-1:-0,arg3=SYSSWCH:0:50
                           =====================================
 JOB: scan1td   Directory: tmp1   DATE: 1997/04/01_13:17:54
 SEARCH PATTERN: UPSI:::-1:+1
 QUALIFIER #1:   DISPLAY:-1:-0
 QUALIFIER #2:   SYSSWCH:0:50
 =======================================================================
 0168 000168        DISPLAY '1'
 0169 000169            UPON UPSI1
 0170 000170                 STOP "CUSMAS1 WRITE ERR".
 0195            0001 matches found in file: tmp1/cobol7.bat
 0039            OPEN OUTPUT LISTFILE.
 0040            DISPLAY '1' UPON UPSI0. SET UPSI1 TO OFF.
 0041            IF UPSI2ON DISPLAY '0' UPON UPSI2,
                  - - - etc (3 more matches removed) - - -
 0048            0004 matches found in file: tmp1/cobolu.bat

 0005 TOTAL MATCHES found in 0018 files in directory: tmp1
 =======================================================================

notes

This is a powerful technique that cannot be duplicated by other Unix utilities such as grep.

Goto:   Begin this document End this document UVSI Home-Page

L1. scan3t - scan for pattern preceded & followed by 2 other patterns

scan3t
  • scan for a pattern that must be followed by a 2nd pattern
    before encountering a 3rd pattern (which may be same as 1st pattern)

 usage: uvcopy scan3t,fili1=infile,arg1=pat1,arg2=pat2,arg3=pat3
        ========================================================

Goto:   Begin this document End this document UVSI Home-Page

M1. scan4d scan directory by table of patterns, report filenames only

scan4d
  • scan a directory searching for matches to a table of patterns
  • report filenames with at least 1 match, or with no matches
note
  • this job reports only the filenames
  • see scanjobs.doc for other jobs (such as scan2d) to report the
    text lines containing the matches

 usage: uvcopy scan4d,fild1=indir,fili2=table,filo1=report
        ==================================================

 demo: uvcopy scan4d,fild1=bat1,fili2=tf/cobol.tbl,filo1=scan4d.rpt,uop=m0n0
       =====================================================================

Goto:   Begin this document End this document UVSI Home-Page

N1. makesf1 - build commands for all filenames in a text file

'makesf1' is a uvcopy job that builds [& executes] 1 specified command for all filenames found within a text file, which is the output of some previous command such as 'grep' or 'scan1d'.

The best example is probably generating 'vi' commands for all files found by a preceding 'grep', 'scan1d', etc. The filenames are identified by '/' (of directory/filename) & an optional qualifier.

vi dir/file1 <-- sample output commands vi dir/file2 vi ---etc---


 usage: uvcopy makesf1,fili1=infile,arg1=command,arg2=qualifier,arg3=outdir
        ===================================================================
  arg1 - specifies the command to be executed on the file
         for example: vi, cat, lp, uvlp, etc (cp if arg3 also spcfd)
  arg2 - may specify a qualifier pattern (also present on same line)
  arg3 - may specify an output directory which will be appended to the
         built-up command for example: cp dir/file outdir

 Ex#1 with output from --> grep sysv1 pf/* >tmp/sysv1
                           ==========================
    doc/TAPEjobs.doc:    sysv1  'tapecntl -p1 $filo1'  position past TpMk
    doc/TAPEjobs.doc:    sysv1  'tapecntl -u $filo1'   rewind & unload
    doc/UVjobs1.doc:    sysv1  'uvlp $filo1'  send report to spooler
    doc/UVjobs1.doc:    sysv1  g0(50)         execute built command

  uvcopy makesf1,fili1=tmp/sysv1,arg1=vi       <-- no qualifier needed
  ======================================
    vi doc/TAPEjobs.doc     #note - multi references reduced to 1
    vi doc/UVjobs1.doc

Goto:   Begin this document End this document UVSI Home-Page

N1a. makesf1 - build commands for all filenames in a text file


 Ex#2 with output from --> uvcopy scan1d,fild1=doc,arg1=sysv1
                           ==================================
        sysv1  'tapecntl -p1 $filo1'  position past TpMk
        sysv1  'tapecntl -u $filo1'   rewind & unload
                                        1 hits @EOF: doc/TAPEjobs.doc
        sysv1  'uvlp $filo1'  send report to spooler
        sysv1  g0(50)         execute built command
                                        1 hits @EOF: doc/UVjobs1.doc

  uvcopy makesf1,fili1=scan1d.aud,arg1=vi,arg2=EOF   <-- qualifier EOF
  ================================================
    vi doc/TAPEjobs.doc      #same output as grep, but did not need reduction
    vi doc/UVjobs1.doc

N2. makesf2 - similar, but creates multiple filenames on 1 command

'makesf2' (for multiple filenames on 1 command) is much better for 'vi' since it is awkward to break out of a script with multiple 'vi' commands. For other commands such as 'cp' or 'rm' etc, it is probably better to use 'makesf1' with separate commands for each filename.


 vi doc/TAPEjobs.doc doc/UVjobs1.doc ...etc...
 ==============================================

N3. makesf3 - multiple filenames on 1 multiline continued\ command

Also see 'makesf3', which creates multiple filenames on 1 command, but uses the '\' script continuation to break the command into multiple lines & prevent 1 very long line.

    vi doc/TAPEjobs.doc doc/UVjobs1.doc doc/UVjobs2.doc doc/uvcopy3.doc \
       doc/uvcopy4.doc doc/uvcopy5.doc doc/versions.doc doc/Y2Kshort.doc \
       doc/Y2Ktools.doc

Goto:   Begin this document End this document UVSI Home-Page

O1. uvcopy parameter file LISTINGS for SCANjobs

Some sections list some uvcopy jobs here at the back of the section. None are listed for this section, but you can list jobs of interest to you, (& file them here for future reference). For example:


 uvlp12 /home/uvadm/pf/scan1d        - list the scan1d job
 ============================
scan1
  • scan a text file (or source program) for any 1 pattern
    & print out all matching lines with their line#s
  • a 2nd pattern (qualifier) may be coded which must be present.
  • a 3rd pattern (qualifier) may be coded which must NOT be present.
scan1d
  • same as scan1 but processes all files within a directory
  • useful when making changes that could affect several files
  • run this job using a relevant keyword(s) to find all the files
    and line#'s that may require changes. Print the audit report &
    use it as your guide when making changes with vi.
scan2
  • scan a text file for matches to a pre-edited table file &
    create a report with matching lines & their line#s
scan2d
  • same as scan2 but processes all files within a directory
    using the same table file format as scan2.
  • the table has 3 columns: search patterns, presence qualifiers,
    & absence qualifiers (pattern lengths determined by 1st tilde)
  • there are many options including 2 table types:
    type1 - qualifiers apply only to search pattern on that line
    type2 - search patterns & qualifiers are independent
scan3d
  • scan all files in a directory & select records to an audit file
    that lie between any 2 specified patterns (start/stop) &
    optionally qualified by a 3rd pattern that must be or must not
    be present between the 1st 2 patterns.
count1d
  • scan all files in a directory reporting lines containing
    specified occurrences of up to 3 patterns. Match conditions
    may be equal, less than, greater than or not equal (=<>!).
count2d
  • scan all files in a directory for up to 3 patterns with
    specified counts & conditions <=!> for each pattern & count
  • reports only file-names not data contents as do other jobs
  • patterns may be anywhere in file, not necessarily on same line
NOTE
  • count1d & count2d are new as of July 1998
  • These powerful jobs can solve problems that are not easily solved
    with any of the standard UNIX utilities.

Goto:   Begin this document End this document UVSI Home-Page

O2. uvcopy parameter file LISTINGS for SCANjobs (continued)

scan1t
  • scan a file for a pattern within a line# range & qualified
    by 1 or 2 other patterns which also have line# ranges.
scan1td
  • same as scan1t, but scan an entire directory of files.
scan3t
  • scan for a pattern that must be followed by a 2nd pattern
    before encountering a 3rd pattern
    (which may be same as 1st pattern)
scan4d
  • scan a directory searching for matches to a table of patterns
  • report filenames with at least 1 match, or with no matches
  • this job reports only the filenames
  • use scan2d to report the text lines containing the matches
makesf1
  • build [& execute] commands for all filenames in a text file
  • example generate 'vi' commands for all files found by a
    preceding 'grep'. Filenames identified by '/' & a qualifier.
makesf2
  • same but creates multiple filenames on 1 command.
makesf2
  • same but creates multiple filenames on 1 command, and breaks
    into multiple lines using '\' continuation.

Goto:   Begin this document End this document UVSI Home-Page

O3. SCANjobs: modifying uvcopy parameter files

Please note that these are advanced examples of uvcopy programming techniques & if you are a beginner, you should 1st study the sections uvcopy1.doc, uvcopy2.doc,& uvcopy3.doc.

You can modify these jobs to accommodate any unique requirements that you may have. For example, if you wanted to increase the max length allowed in the table files of patterns for the scan or rep jobs, you could re-edit the table file & the prmfile.

Note that the SCANjobs have standardized the table entry length to 80 bytes (the screen width) 01-30 - the search pattern 31-60 - the present qualifier pattern (or tildes if not used) 60-80 - the absent, or 2nd present if option p2 (tildes if not used)

If you decided to make a new version of scan2 or scan2d that would allow 01-40 for the search pattern, 41-60 for presence,& 61-80 for absence you might proceed as follows:

  1. edit your new scan2tbl1 as above
  2. copy scan2 to a new name (scan240 for example)
  3. edit your new job - looking for the following instructions:

rtb fili2,p0(80),p0(80) - loads table, entry lth needs no change

    wtb   filo2,p0(80),h0(80)   - writes table to audit report file
                                  (entry lth needs no change)
    scto1  ac0($rd256),pp0(80),pp0(30)
                                - searches the table of 80 byte entries
                                > change op3 to 40 byte search length
    scno1  a0(256),pp30(30)
                                - scanning for presence qualifier
                                > change to op2 to 20 byte length
    scno1  a0(256),pp60(20)
                                - scanning for absence qualifier
                                > OK as is

Goto:   Begin this document End this document UVSI Home-Page

Visitor Counters for ThisYear and LastYear