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 REPjobs |
A2. | Verifying your mass changes |
B1. | Test/demo files supplied to demonstrate the REPjobs |
tf/names1, tf/names2, tf/test100 |
Features common to most REPjobs C1. command line arguments (arg1-arg9) standard assignments C2. pattern match characters (@=any alpha, #=any numeric, etc) C3. tables used by REPjobs (rep2 & rep2d)
D1. | rep1 - scan a text file (or source program) for any 1 pattern |
& replace it with an alternate pattern | |
- filenames & search/replace patterns may be specified on the | |
command line, or if not they will be solicited from the operator. | |
- qualifying patterns may be present or not present for valid match. | |
- an audit report is created showing changed lines & their line#s. |
E0. | rep1d - same as rep1 but processes all files within a directory |
- all files will be copied into a new directory. You would spot | |
check to ensure proper replacements before changing the | |
directory name back to the original name. |
F1. | rep2 - scan a text file for matches to a table file containing columns |
of search patterns, replacements,& optional qualifiers. | |
- patterns & alternates will be pre-edited into a file whose | |
name may be specified on the command line or (solicited). | |
- the table also has optional 3rd & 4th columns for qualifying | |
patterns which must be present or not present for a valid match. |
G1. | rep2d - same as rep2 but processes all files within a directory |
- all files will be copied to a new directory that may be | |
spot checked before renaming as the original. |
I0. | Listings of the uvcopy instructions for some of these jobs. |
Goto: Begin this document , End this document , UVSI Home-Page
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 (& replace).
To familiarize yourself with these jobs I have provided test files, detailed operating instructions,& expected results. Please run these & compare your results to the expected results.
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 the next 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.
The maximum record length processed by these jobs is 256 bytes. User option 'd' specifies the length to be scanned & this defaults to 128 bytes, but you can increase this to the max rcsz by replying 'd256' at the prompt for user option default changes.
If the 256 record length is insufficient for you, you could easily change the code on the various instructions (get, mvc, scn, rep, put).
Goto: Begin this document , End this document , UVSI Home-Page
Of course you will be hesitant about mass changing your programs with a new tool & especially when mass changing the entire directory which of course is the main idea here. Note that these mass change jobs always copy your input directory to an output directory which you would check before changing the name back to the original.
The REPjobs create audit trail reports of changed records, but for an independent verification, I have provided the 'alldiff' script which repeats the UNIX 'diff' command for all files in the directory (see the alldiff script listed at scripts1.htm#4A1).
For example if you run rep1d (or rep2d) to make mass changes to your 'cobsrc' directory while copying over to a 'tmp' directory, you can check it as shown below. The sample rep1d below converts the word 'MAINFRAME' to 'UNIX', but you would substitute your words here. To perform multiple search/replacements you would use 'rep2d' & pre-edit a table of search & replace patterns.
1. uvcopy rep1d,fild1=cobsrc,fild2=tmp,arg1=MAINFRAME,arg2=UNIX ============================================================
2. vi rep1d.aud - examine audit report from rep1d ============
3. alldiff cobsrc tmp >diffreport - compare original to changed directory ============================== & create a difference report
4. vi diffreport - inspect the difference report =============
Goto: Begin this document , End this document , UVSI Home-Page
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.
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
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
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 rep jobs such as rep1 or rep2.
The advantage of tf/test100 is that the results are predictable, you can instantly evaluate the results of your reps for various patterns, replacements,& qualifiers, for example:
uvcopy rep1,fili1=tf/test100,arg1=nine,arg2=NINE,arg3=~,arg4=ninety ===================================================================
This would change 'nine' to 'NINE' but 'ninety' must be ABSENT from the same line. (the PRESENT qualifier is disabled via 'arg3=~').
Goto: Begin this document , End this document , UVSI Home-Page
You can run these jobs 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 'rep1' which will scan only 1 file searching for 1 pattern, replacing with 1 alternate,& creating a report with modified lines, their line#s,& total reps by file.
rep1 is good for illustrations because it only processes 1 file, however rep1d is much more useful because it processes all files in a directory. (ie - you would probably use 'vi' for 1 file, but rep1d for a directory)
Note that rep2 & rep2d do not use arg1,arg2,arg3 because the search patterns & qualifiers are specified in a table. Also note that arguments 6,7,8,9 are standard for most jobs.
uvcopy rep1 - will prompt for filename,arguments,& options =========== - command below specifies all data (no prompts)
uvcopy rep1,fili1=file,arg1=search-pattern,arg2=replacement-pattern =================================================================== ,arg3=qualifier-present,arg4=qualifier-absent,arg6=repbgn,arg7=repend ===================================================================== ,arg8=match-options,arg9=report-disposition,uop=user-options ============================================================
ex#1: uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Iceland ====================================================
ex#2: uvcopy rep1,fili1=names1,arg1=Canada,arg2=Iceland,arg3=~,arg4=~ ===============================================================
ex#3: uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Iceland,arg3=~,arg4=BC =================================================================
ex#4: uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Iceland,uop=q0a1b999c0d128 =======================================================================
ex#5: uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Ice,arg6=Datex,arg7=Unisys =======================================================================
note |
|
Goto: Begin this document , End this document , UVSI Home-Page
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 |
|
arg2 |
|
arg3 |
|
note |
|
arg4 |
|
arg6 |
|
arg7 |
|
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 |
|
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
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#
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 present qual(31-60) & 1 absent qual(61-80)' p2 - 2 present quals(31-60+61-80) & NO absent qual'
User OPtion (uop) defaults = q1a1b99999c0d128p1 null to accept or re-specify (1 or more) -->
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
Goto: Begin this document , End this document , UVSI Home-Page
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
You can run the 'rep1' job as much as you like experimenting with different search patterns & replacements (longer, shorter, etc). Note that the default input file is listed on page B1 of this section. Some other suggested patterns (that will get more than 1 hit) are:
search replace data result Dr. Drive Victoria Dr. Victoria Drive
Vancouver Lotus Land Vancouver BC Lotus Land BC
V5P V5P |
|
** rep options 'ps' ** ----------------------
option 'ps' (entered at the option prompt) is a very powerful feature that allows you to code the special pattern match characters in the replacement data as well as in the search data patterns, for example:
search replace data result ---------------------------------------------------------
1 @#@ #@# @#@ - #@# V5P 3V8 V5P - 3V8 L4Z 2G6 L4Z - 2G6
1 - as you can see the 'ps' option allows you to insert constants within the data recognized by the special match characters
2 - This example uses the '*' (match any number of preceding characters) to enforce a uniform 1 blank between the 2 halves of the postal code
3 - This example converts telephone #s from the AAA-XXX-NNNN format to the (AAA) XXX-NNNN format
? - Keep this powerful feature in mind, I am sure you will run across many situations where you can put it to work.
Goto: Begin this document , End this document , UVSI Home-Page
# tf/rep2tbl - table file to demo: pf/rep2 & pf/rep2d jobs # 001-030 - search pattern (ended by 1st tilde) # 031-060 - replacement pattern (ended by 1st tilde) # 061-080 - optional PRESENT qualifier # 081-100 - optional NOT-PRESENT qualifier # note - table may be illustrated as 20+20+20+20 to fit documentation # - @(any alpha), #(any numeric) requires option 'p' or 'ps'(in replace) # Vancouver~~~~~~~~~~~LOTUS LAND~~~~~~~~~~Canada~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ Canada ~~~~~~~~~~~~ Iceland ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ ###-###-~~~~~~~~~~~~(###) ###-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~ (end table marker '~~' in col 1&2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As noted above in the table #comment lines, the table is illustrated as 80 byte entries of 20+20+20+20 to fit this documentation.
In reality the REPjob tables have been standardized as 100 byte entries with 30 for the search-pattern, 30 for the replacement-pattern, 20 for the PRESENT qualifier,& 20 for the NOT-PRESENT qualifier.
The best way to understand these jobs is to run rep2 & rep2d with the test/demo files provided (tf/names1, tf/names2, etc).
Please see the rep2 & rep2d 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
rep1 will be run several times with different search patterns,replacements, 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.
uvcopy rep1 - execute uvcopy to interpret prmfile 'scan1' =========== NOTE - no args on command line causes prompts below:
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 present qual(31-60) & 1 absent qual(61-80)' p2 - 2 present quals(31-60+61-80) & NO absent qual' User OPtion defaults = q1a1b99999c0d128p1 --> <-- accept dflt optns
tf/names1 = default fili1 - null accept or reenter ? --> <-- accept dflt infile enter your search pattern (max 64 bytes) --> Canada <-- search pattern enter your replacement pattern (max 64 bytes) --> Iceland <-- replacement enter qualifier present (null to disable) --> <-- null to disable enter qual absent, or 2nd present if option p2 --> <-- null to disable match options: p=matchchars(@,#,etc), s=matchchars in replace quote inhibits: q1=no scan within singles,q2=doubles,q3=both enter match options: p,s,q1/q2/q3,n,or null --> <-- null to disable EOF fili1 35 rds, 0 wrts, 5 hits, 470 size, fname=tf/names1 EOF filo1 0 rds, 35 wrts, 5 hits, 475 size, fname=rep1.tmp EOF filo2 0 rds, 10 wrts, 5 hits, 456 size, fname=rep1.aud display/edit/print/none ? (enter: cat/vi/lp[-dp?]/null) --> vi <-- inspect with vi ** sample report **
JOB: rep1 file: tf/names1 search: Canada replace: Iceland qualifier present: ~ absent: ~ scanbgn: scanend: matchops: n userops: q1a1b99999c0d128q0 ====================================================== 1995/11/23_11:12:11 00004 Vancouver BC Iceland 00010 Vancouver, BC Iceland 00016 Vancouver BC Iceland 00026 Unisys Iceland Inc. 00029 Iceland M2J 4Z7 00034 Ottawa, Iceland ====================================================== 1995/11/23_11:12:11 EOF: replacements made in 00006 of 00035 lines
Goto: Begin this document , End this document , UVSI Home-Page
The 1st run specified no arguments on the command line & we were prompted for all arguments. This & subsequent runs will specify the significant arguments on the command line to avoid the prompts & so you can repeat commands using the KORN shell history. Arguments that default OK, are omitted from the command line since it is easier to just hit enter.
The output report filename defaults to jobname.aud (rep1.aud, rep2.aud, etc) You are prompted for a command to display/print/... the output file. I suggest you reply 'vi' to display or 'cat' if the file is short.
1 - scan tf/names1 replacing 'Canada' with 'Iceland'. *2 - scan tf/names1 replacing 'Canada' with 'Iceland' but not if 'BC'. 3 - scan tf/names1 replacing 'Canada' with 'Iceland' but only after 'Datex' has been detected & not after 'Unisys' is detected. 4 - scan tf/names1 converting postal codes blank separators to hyphens
uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Iceland,arg3=~,arg4=BC =================================================================== ^ ^^
JOB: rep1 file: tf/names1 search: Canada replace: Iceland qualifier present: ~ absent: BC scanbgn: scanend: matchops: n userops: q1a1b99999c0d128q0 ====================================================== 1995/11/23_11:14:46 00026 Unisys Iceland Inc. 00029 Iceland M2J 4Z7 00034 Ottawa, Iceland ====================================================== 1995/11/23_11:14:46 EOF: replacements made in 00003 of 00035 lines
Please compare this audit report to the previous page & note that the NOT-present qualifier of 'BC' has reduced the replacements from 5 to 2. (the presence qualifier is disabled by specifying as 'arg3=~').
Goto: Begin this document , End this document , UVSI Home-Page
1 - scan tf/names1 replacing 'Canada' with 'Iceland'. 2 - scan tf/names1 replacing 'Canada' with 'Iceland' but not if 'BC'. *3 - scan tf/names1 replacing 'Canada' with 'Iceland' but only after 'Datex' has been detected & not after 'Unisys' is detected. 4 - scan tf/names1 converting postal codes blank separators to hyphens
uvcopy rep1,fili1=tf/names1,arg1=Canada,arg2=Iceland,arg6=Datex,arg7=Unisys ===========================================================================
JOB: rep1 file: tf/names1 search: Canada replace: Iceland qualifier present: ~ absent: ~ scanbgn: Datex scanend: Unisys matchops: n userops: q1a1b99999c0d128q0 ====================================================== 1995/11/23_11:16:02 00010 Vancouver, BC Iceland 00016 Vancouver BC Iceland ====================================================== 1995/11/23_11:16:03 EOF: replacements made in 00002 of 00035 lines
Please compare this report to rep1 (run#1) & note that the replacements have been reduced from 5 to 2, because of the search start/stop arg6/arg7. 'arg6=Datex' disables the replacements until 'Datex' is detected 'arg7=Unisys' disables the replacements after 'Unisys' is detected
Also note that you can specify start/stop via line#s as well as patterns 'uop=a6b25' would disable replacements until line #6 & after line #25.
You can also limit the scan column range via uops c & d. The default is uop=c0d128 which means from column 1 for a length of 128.
--> Try experimenting with these options using the uvadm/tf/names2 file of delimited records (about 80 bytes long).
Goto: Begin this document , End this document , UVSI Home-Page
1 - scan tf/names1 replacing 'Canada' with 'Iceland'. 2 - scan tf/names1 replacing 'Canada' with 'Iceland' but not if 'BC'. 3 - scan tf/names1 replacing 'Canada' with 'Iceland' but only after 'Datex' has been detected & not after 'Unisys' is detected. *4 - scan tf/names1 converting postal codes blank separators to hyphens
uvcopy rep1,fili1=tf/names1,arg1u=@#@_*#@#,arg2=@#@-#@#,arg8=ps =============================================================== ^^
JOB: rep1 file: tf/names1 search: @#@ *#@# replace: @#@-#@# qualifier present: ~ absent: ~ scanbgn: scanend: matchops: ps userops: q1a1b99999c0d128q0 ====================================================== 1995/11/23_11:20:51 00005 V5P-3V8 604-321-1024 00011 V5P-3V8 604-321-5822 00017 V4V-1X1 00023 L4Z-2G6 00029 Canada M2J-4Z7 00035 ON K1Y-2L6 ====================================================== 1995/11/23_11:20:51 EOF: replacements made in 00006 of 00035 lines
Please compare these results to the original file listed on page B1 & note that the postal codes have been converted from 1 or more blank separators to 1 hyphen. The match-option 'arg8=ps' is required, the 'p' activates the match chars (@=any alpha, #=any numeric, etc) & the 's' also allows the match chars to be used in the output pattern to represent the input data.
Also note that option u is necessary on 'arg1u=@#@_*#@#' to convert the underscore to the intended blank (because embedded blanks are not allowed on the command line).
--> Try your own experiments with these test files or your own data files using whatever search patterns, qualifiers,& options make sense to you.
Goto: Begin this document , End this document , UVSI Home-Page
uvcopy rep1d <-- NO arguments on command line ============ causes prompts for directories, patterns,& options
uop=q1a1b99999c0d256e0p1 - 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 d256 - length of scan area default 256 bytes e0 - do not erase any output files e1 - erase output files with no replacements p1 - 1 present qual(31-60) & 1 absent qual(61-80)' p2 - 2 present quals(31-60+61-80) & NO absent qual' User OPtion defaults = q1a1b99999c0d256e0p1 null to accept or re-specify (1 or more) --> <-- default user optns
tf = default fild1 - null accept or reenter ? --> <-- accept dflt indir tmp = default fild2 - null accept or reenter ? --> <-- accept dflt outdir did you create output directory or remove files ? (dflt tmp) --> y <-- (reply y or kill) enter your search pattern (max 64 bytes) --> Canada <-- search pattern enter your replacement pattern (max 64 bytes) --> Iceland <-- replacement enter qualifier present (null to disable) --> ON <-- present qualifier enter qual absent, or 2nd present if option p2 --> BC <-- NOT present qual match options: p=matchchars(@,#,etc), s=matchchars in replace quote inhibits: q1=no scan within singles,q2=doubles,q3=both enter match options: p,s,q1/q2/q3,n,or null --> <-- null to disable display/edit/print/none ? (enter: cat/vi/lp[-dp?]/null) --> vi <-- vi to inspect
EOF fili1 5 rds, 0 wrts, 1 hits, 107 size, fname=tf/OTadrs EOF filo2 0 rds, 5 wrts, 1 hits, 81 size, fname=tmp/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 EOF filo2 0 rds, 2 wrts, 0 hits, 499 size, fname=tmp/PDF.DBF - - - - - etc - - - - - EOF fili1 5 rds, 0 wrts, 1 hits, 135 size, fname=tf/UVadrs EOF filo2 0 rds, 5 wrts, 1 hits, 92 size, fname=tmp/UVadrs EOF filo3 0 rds, 61 wrts, 29 hits, 2887 size, fname=rep1d.aud EOF fild1 97 rds, 0 wrts, 29 hits, 1584 size, fname=tf EOF fild2 0 rds, 0 wrts, 29 hits, 1568 size, fname=tmp
Goto: Begin this document , End this document , UVSI Home-Page
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 tmp1 - copy 2 files to the tmp1 directory =====================
The following demos of rep1d 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
Rep1d can perform search/replacements in 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 2 files into it from the uvadm/tf directory (names1 & names2).
We will demonstrate rep1d using the following 2 test situations:
*1 - copy the tmp1 directory to tmp replacing 'Vancouver' with 'Lotusland' if 'BC' is present on the same line.
2 - copy the tmp1 directory to tmp replacing 'Canada' with 'Iceland' if 'BC' is NOT present on the same line.
uvcopy rep1d,fild1=tmp1,fild2=tmp,arg1=Vancouver,arg2=LotusLand,arg3=BC ======================================================================= ^^^^
JOB: rep1d indir: tmp1 outdir: tmp search: Vancouver replace: LotusLand qualifier-present: BC absent: ~ scanbgn: scanend: match-options: user-options: q1a1b99999c0d128 ====================================================== 1995/11/23_10:26:22 00004 LotusLand BC Canada 00010 LotusLand, BC Canada 00016 LotusLand BC Canada 00035 3 reps @EOF: tmp/names1
00001 "Owen Townsend","UV Software","5436 Victoria Dr","LotusLand BC Canada","V5P 3V8 604-321-1024" 00002 "Sid Treur","Datex Services","5436 Victoria Dr","LotusLand, BC Canada","V5P 3V8 604-321-5822" 00003 "Pavel Bure","(the Russian Rocket)","GM Place","LotusLand BC Canada","V4V 1X1" 00006 3 reps @EOF: tmp/names2
====================================================== 1995/11/23_10:26:22 EOD: 00006 reps in 0002 files of 0002 total (00041 lines)
Please compare this result with rep1d run#2 (next page) & note that the qualifier 'BC' present or NOT present causes a different set of records to be modified.
Goto: Begin this document , End this document , UVSI Home-Page
1 - copy the tmp1 directory to tmp replacing 'Vancouver' with 'Lotusland' if 'BC' is present on the same line.
*2 - copy the tmp1 directory to tmp replacing 'Canada' with 'Iceland' if 'BC' is NOT present on the same line.
Note |
|
uvcopy rep1d,fild1=tmp1,fild2=tmp,arg1=Canada,arg2=Iceland,arg3=~,arg4=BC ========================================================================= ^^^^
JOB: rep1d indir: tmp1 outdir: tmp search: Canada replace: Iceland qualifier-present: ON absent: BC scanbgn: scanend: match-options: user-options: q1a1b99999c0d128 ====================================================== 1995/11/23_10:13:28 00005 "R. Dainty","Unisys Iceland Inc.","2001 Sheppard Ave E","Toronto, ON","Iceland M2J 4Z7" 00006 "J. Chretien","Prime Minister","24 Sussex Drive","Ottawa, Iceland","ON K1Y 2L6" 00006 2 reps @EOF: tmp/names2
00005 R. Dainty;Unisys Iceland Inc.;2001 Sheppard Ave E;Toronto, ON Iceland M2J 4Z7 00006 J. Chretien;Prime Minister;24 Sussex Drive;Ottawa, Iceland;ON K1Y 2L6 00006 2 reps @EOF: tmp/names3
====================================================== 1995/11/23_10:13:28 EOD: 00004 reps in 0002 files of 0003 total (00047 lines)
Please compare this result with rep1d run#1 (previous page) & note that the qualifier 'BC' present or NOT present causes a different set of records to be modified.
--> Try some more experiments using these test files or your own data files & specifying whatever search patterns, replacements, qualifiers,& options make sense to you.
Goto: Begin this document , End this document , UVSI Home-Page
uvcopy rep2 <-- NO arguments on command line =========== causes prompts for directories, 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 present qual(31-60) & 1 absent qual(61-80)' p2 - 2 present quals(31-60+61-80) & NO absent qual' User OPtion defaults = q1a1b99999c0d128p1 null to accept or re-specify (1 or more) -->
tf/names1 = default fili1 - null accept or reenter ? --> <-- default input file tf/rep2tbl = default fili2 - null accept or reenter ? --> <-- default table file rep2.tmp = default filo1 - null accept or reenter ? --> <-- default output file match options: p=matchchars(@,#,etc), s=matchchars in replace quote inhibits: q1=no scan within singles,q2=doubles,q3=both enter match options: p,s,q1/q2/q3,n,or null --> <-- default match options EOF fili1 35 rds, 0 wrts, 5 hits, 470 size, fname=tf/names1 EOF fili2 11 rds, 0 wrts, 0 hits, 796 size, fname=tf/rep2tbl EOF filo1 0 rds, 35 wrts, 5 hits, 478 size, fname=rep2.tmp EOF filo2 0 rds, 14 wrts, 5 hits, 942 size, fname=rep2.aud
display/edit/print/none ? (enter: cat/vi/lp[-dp?]/null) --> vi <-- inspect report
JOB: rep2 infile: tf/names1 outfile: rep2.tmp table: tf/rep2tbl scanbgn: scanend: match-optns: ndfg user-optns: q1a1b99999c0d128q0 ====================================================== 1995/11/24_15:18:36 Vancouver~~~~~~~~~~~LOTUS LAND~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~ Canada ~~~~~~~~~~~~ Iceland ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ ###-###-~~~~~~~~~~~~(###) ###-~~~~~~~~~~V5P~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ====================================================== 1995/11/24_15:18:36 00004 LOTUS LAND BC Canada 00010 LOTUS LAND, BC Canada 00016 LOTUS LAND BC Canada 00026 Unisys Iceland Inc. 00034 Ottawa, Iceland ====================================================== 1995/11/24_15:18:36 EOF: 00005 reps on 00005 lines of 00035 total line
Goto: Begin this document , End this document , UVSI Home-Page
1 - copy the uvadm/names1 demo file replacing by table - no options
*2 - copy the uvadm/names1 demo file replacing by table - 'ps' options - option 'p' allows match chars in search pattern (@=any alpha, #=any num) - option 's' allows match chars in replacement (to reformat data)
uvcopy rep2,fili1=tf/names1,fili2=tf/rep2tbl,filo2=rep2.aud,arg8=ps =================================================================== ^^
JOB: rep2 infile: tf/names1 outfile: rep2.tmp table: tf/rep2tbl scanbgn: scanend: match-optns: psdfg user-optns: q1a1b99999c0d128q0 ====================================================== 1995/11/24_15:14:08 Vancouver~~~~~~~~~~~LOTUS LAND~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~ Canada ~~~~~~~~~~~~ Iceland ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ ###-###-~~~~~~~~~~~~(###) ###-~~~~~~~~~~V5P~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ====================================================== 1995/11/24_15:14:08 00004 LOTUS LAND BC Canada 00005 V5P 3V8 (604) 321-1024 00010 LOTUS LAND, BC Canada 00011 V5P 3V8 (604) 321-5822 00016 LOTUS LAND BC Canada 00026 Unisys Iceland Inc. 00034 Ottawa, Iceland ====================================================== 1995/11/24_15:14:09 EOF: 00007 reps on 00007 lines of 00035 total line
Compare this report to run#1 on the previous page. The only difference is that the match/replace options are on here on run#2 but not run#1.
'arg8=ps' activates the ###-###- table entry which matches phone#s & changes the format to (###) ###-.
For illustration purposes I have modified the table above to: 01-20 search, 21-40 replace, 41-60 qual present, 61-80 qual absent (vs actual: 01-30, 31-60, 61-80, 81-100)
Goto: Begin this document , End this document , UVSI Home-Page
uvcopy rep2d <-- NO arguments on command line ============ causes prompts for directories, patterns,& options
uop=q1a1b99999c0d256e0p1 - 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 d256 - length of scan area default 256 bytes e0 - do not erase any output files e1 - erase output files with no replacements p1 - 1 present qual(31-60) & 1 absent qual(61-80)' p2 - 2 present quals(31-60+61-80) & NO absent qual'
User OPtion defaults = q1a1b99999c0d256e0p1 null to accept or re-specify (1 or more) --> <-- default user options
tf = default fild1 - null accept or reenter ? --> <-- default input dir tf/rep2tbl = default fili3 - null accept or reenter ? --> <-- default table file did you create out dir (dflt tmp) ? or remove all files ? --> y <-- (reply y or kill) tmp = default fild2 - null accept or reenter ? --> <-- default output dir match options: p=matchchars(@,#,etc), s=matchchars in replace quote inhibits: q1=no scan within singles,q2=doubles,q3=both enter match options: p,s,q1/q2/q3,n,or null --> <-- no match options ^^^^^^^^^^^^^^^^
display/edit/print/none ? (enter: cat/vi/lp[-dp?]/null) --> vi <-- inspect report **see audit report on next page ------------------------------>
EOF fili1 5 rds, 0 wrts, 1 hits, 107 size, fname=tf/OTadrs EOF filo2 0 rds, 5 wrts, 1 hits, 81 size, fname=tmp/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 EOF filo2 0 rds, 2 wrts, 0 hits, 499 size, fname=tmp/PDF.DBF - - - - - etc - - - - -
NOTE |
|
Goto: Begin this document , End this document , UVSI Home-Page
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 tf/names1 tf/names2 tmp1 <-- copy 2 files to the tmp1 directory ===========================
The following demos of rep2d 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
*1 - copy tmp1 directory to tmp replacing by table - no options
2 - copy tmp1 directory to tmp replacing by table - 'ps' options
Note |
|
uvcopy rep2d,fild1=tmp1,fild2=tmp,fili3=tf/rep2tbl,arg8=n ========================================================= ^^^^ ^
JOB: rep2d indir: tmp1 outdir: tmp table: tf/rep2tbl scanbgn: scanend: match-optns: ndfg user-optns: q1a1b99999c0d128q0 ====================================================== 1995/11/24_15:22:00 Vancouver~~~~~~~~~~~LOTUS LAND~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~ Canada ~~~~~~~~~~~~ Iceland ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ ###-###-~~~~~~~~~~~~(###) ###-~~~~~~~~~~V5P~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ====================================================== 1995/11/24_15:22:00 00004 LOTUS LAND BC Canada 00010 LOTUS LAND, BC Canada 00016 LOTUS LAND BC Canada 00026 Unisys Iceland Inc. 00034 Ottawa, Iceland 00035 5 reps @EOF: tmp/names1
00001 "Owen Townsend","UV Software","5436 Victoria Dr","LOTUS LAND BC Canada","V5P 3V8 604-321-1024" 00002 "Sid Treur","Datex Services","5436 Victoria Dr","LOTUS LAND, BC Canada","V5P 3V8 604-321-5822" 00003 "Pavel Bure","(the Russian Rocket)","GM Place","LOTUS LAND BC Canada","V4V 1X1" 00005 "R. Dainty","Unisys Iceland Inc.","2001 Sheppard Ave E","Toronto, ON","Canada M2J 4Z7" 00006 4 reps @EOF: tmp/names2
====================================================== 1995/11/24_15:22:00 EOD: 00009 reps in 0002 files of 0002 total (00041 lines)
note |
|
Goto: Begin this document , End this document , UVSI Home-Page
1 - copy tmp1 directory to tmp replacing by table - no options
*2 - copy tmp1 directory to tmp replacing by table - 'ps' options - option 'p' allows match chars in search pattern (@=any alpha, #=any num) - option 's' allows match chars in replacement (to reformat data)
Note |
|
uvcopy rep2d,fild1=tmp1,fild2=tmp,fili3=tf/rep2tbl,arg8=ps ========================================================== ^^^^ ^^
JOB: rep2d indir: tmp1 outdir: tmp table: tf/rep2tbl scanbgn: scanend: match-optns: psdfg user-optns: q1a1b99999c0d128q0 ====================================================== 1995/11/24_15:22:34 Vancouver~~~~~~~~~~~LOTUS LAND~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ON~~~~~~~~~~~~~~~~~~ Canada ~~~~~~~~~~~~ Iceland ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BC~~~~~~~~~~~~~~~~~~ ###-###-~~~~~~~~~~~~(###) ###-~~~~~~~~~~V5P~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ====================================================== 1995/11/24_15:22:34 00004 LOTUS LAND BC Canada 00005 V5P 3V8 (604) 321-1024 00010 LOTUS LAND, BC Canada 00011 V5P 3V8 (604) 321-5822 00016 LOTUS LAND BC Canada 00026 Unisys Iceland Inc. 00034 Ottawa, Iceland 00035 7 reps @EOF: tmp/names1
00001 "Owen Townsend","UV Software","5436 Victoria Dr","LOTUS LAND BC Canada","V5P 3V8 (604) 321-1024" 00002 "Sid Treur","Datex Services","5436 Victoria Dr","LOTUS LAND, BC Canada","V5P 3V8 (604) 321-5822" 00003 "Pavel Bure","(the Russian Rocket)","GM Place","LOTUS LAND BC Canada","V4V 1X1" 00005 "R. Dainty","Unisys Iceland Inc.","2001 Sheppard Ave E","Toronto, ON","Canada M2J 4Z7" 00006 6 reps @EOF: tmp/names2
====================================================== 1995/11/24_15:22:34 EOD: 00013 reps in 0002 files of 0002 total (00041 lines)
note |
|
Goto: Begin this document , End this document , UVSI Home-Page
note |
|
mkdir pfdos - make a directory to receive output
uvcopy rep2d,fild1=pf,fild2=pfdos,fili1=tf/pfdos.tbl ====================================================
note |
|
did you create output directory (or remove all files) ? ---> y
*** sample output ***
JOB: rep2d indir: pf outdir: tmp --------------------------------- rep table file: tf/pfdos.tbl pf/~~~~~~~~~~~~~~~~~~~~~~~~~~~pf\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tf/~~~~~~~~~~~~~~~~~~~~~~~~~~~tf\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tf3/~~~~~~~~~~~~~~~~~~~~~~~~~~tf3\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 'lp ~~~~~~~~~~~~~~~~~~~~~~~~~~'print ~~~~~~~~~~~~~~~~~~~~~~~sys~~~~~~~~~~~~~~~~~ 'cat ~~~~~~~~~~~~~~~~~~~~~~~~~'type ~~~~~~~~~~~~~~~~~~~~~~~~sys~~~~~~~~~~~~~~~~~ cat/vi/lp[-dp?]~~~~~~~~~~~~~~~type/edit/print~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cat/vi/lp~~~~~~~~~~~~~~~~~~~~~type/edit/print~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lp/cat~~~~~~~~~~~~~~~~~~~~~~~~print/display~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cat/lp~~~~~~~~~~~~~~~~~~~~~~~~display/print~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -onobanner~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -oraw~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ end table marked by '~~' in columns 1 & 2 ~~~~~~~~~~~~~~~~~~~~~~ -------------------------------------------------------- 19951016 1118 00011 fili1=?tf\dataent,rcs=a80,typ=LST 00035 sysv1 'type $filo1' 00043 2 reps @EOF: tmp/enter1
00013 fili1=?tf\names1,typ=LST,rcs=256 # test file of 6 N&A sets 00046 msgw 'display/edit/print/none ? (enter: type/edit/print/null)' 00062 2 reps @EOF: tmp/NAlist1
00011 fili1=?tf\uvintro,rcs=128,typ=LST 00012 fili2=?tf\uvcaps.tbl,rcs=128,typ=LST 00036 2 reps @EOF: tmp/uvcaps EOD: 00386 reps in 0168 files of 0253 total (24708 lines)
Goto: Begin this document , End this document , UVSI Home-Page
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/rep1d - list the rep1d job ===========================
D1. | rep1 - scan a text file (or source program) for any 1 pattern |
& replace it with an alternate pattern | |
- filenames & search/replace patterns may be specified on the | |
command line, or if not they will be solicited from the operator. | |
- qualifying patterns may be specified which must be present | |
&/or not present for a valid match. | |
- NOT listed here but readily available in the uvadm/pf directory. | |
(similar to 'rep1d' which is the more useful job) |
E1. | rep1d - same as rep1 but processes all files within a directory |
- all files will be copied into a new directory. You would spot | |
check to ensure proper replacements before changing the | |
directory name back to the original name. |
F1. | rep2 - scan a text file for matches to a table file containing columns |
of search patterns, replacements,& optional qualifiers. | |
- patterns & alternates will be pre-edited into a file whose | |
name may be specified on the command line or (solicited). | |
- the table also has optional 3rd & 4th columns for qualifying | |
patterns which must be present or not present for a valid match. | |
- NOT listed here since it is similar to 'rep2d' which more useful. |
G1. | rep2d - same as rep2 but processes all files within a directory |
- all files will be copied to a new directory that may be | |
spot checked before renaming as the original. |
H1. | rep3d - search/replace blocks of code in all files in a directory. |
- blocks to be replaced may be identified by a starting pattern, | |
an ending pattern,& a qualifying pattern, which must exist | |
between the 1st 2 patterns. |
Goto: Begin this document , End this document , UVSI Home-Page