| A1. | Overview & Free Software notice (GNU FSF GPLv3) |
| B1. | Download uvhd.c source from www.uvsoftware.ca & Compile for Unix/Linux |
| B2. | Download uvhd.exe from www.uvsoftware.ca for Windows/DOS |
| B3. | Customizing the DOS Command Prompt window for Windows 2000 |
| - changing small, ugly, black & white default to big, blue,& beautiful | |
| B4. | Compiling uvhd.c to uvhd.exe on Windows/DOS (using lcc-win32) |
| - not required, since you can download uvhd.exe from www.uvsoftware.ca |
| C1. | Customization re printing |
| D1. | uvhd Display format |
| D2. | Warning for Fixed record lengths not evenly divisible into filesize |
| - uvhd calculates the next lower/higher record sizes evenly divisible |
| E1. | Help screens |
| F1. | uvhd option summary |
| F4. | uvhd command summary |
| G1. | uvhd Function summary |
| H1. | uvhd Tutorial Preparation |
| I1. | Browsing - demo for ASCII file with packed fields |
| - display records consecutively | |
| - jump to & display any record in the file by record# | |
| I2. | Browsing - demo for EBCDIC file with packed fields |
| J1. | Search - search by pattern, anywhere in the record (by default) |
| or within specified column locations | |
| - may search on 1 or 2 fields with AND/OR relationships | |
| - match data =,>,< equal(default), greater than, less than | |
| - repeat previous search via 'ss' vs 's' + search args | |
| - search backward via 'sb' or 'ssb' | |
| J2. | Search Indexed files for deleted records |
| - applies to D-ISAM, C-ISAM,& MF COBOL IDXFORMAT1 | |
| - a useful application for uvhd | |
| - also illustrates how to count (enumerate) deleted records |
| K1. | Update - update the current record on display |
| - specified columns replaced with specified data (char/hex) | |
| - option to rollback current record updates | |
| - option for multi-record updates with 1 qualifier field |
| L1. | Scan/Replace - searches the specified record field, searching for a pattern |
| - if found, replace with a replacement pattern. | |
| - will truncate or blank fill if search & replace lengths different | |
| - for fixed length records, use with fields such as Name & Address | |
| - most effective with variable length text records. |
Goto: Begin this document , End this document , UVSI Home-Page
| M1. | Write - write Unformatted records to a file: tmp/fname.yymmddhhmmW |
| for subsequent use as test files, etc. | |
| - may specify number of records from current position | |
| or records matching 1 or 2 patterns within specified columns | |
| - select specified records from big files for small test files |
| N1. | Print - write formatted records to tmp file for later lp,uvlp,etc |
| - output file will be: tmp/filename.yymmddhhmmP | |
| - may specify a number of records from current position | |
| - may specify records matching 1 or 2 patterns & a max count | |
| - To actually print, you must quit uvhd & select the desired | |
| filename from the tmp directory. |
| O1. | Iprint - write formatted records to a file for immediate printing |
| via the 'uvlp' command (see uvlist.doc). | |
| - may specify a number of records &/or records matching | |
| 1 or 2 specified patterns within specified columns. |
| P1. | Generate Sequence Numbers |
| - may specify starting number & increment (default 1) | |
| - may specify constants before & after sequence# |
| Q1. | Check - check sequence of specified field |
| - options for ascending, descending, duplicates |
| R1. | Enumerate - count records from current position matching 1 or 2 |
| specified patterns until EOF or within a max record count |
| S1. | Translate - to Ascii, Ebcdic, Upper, Lower, Characters, Periods |
| - unprintable characters can be translated to blanks or Periods |
| T1. | Drop - copy to tmp file, dropping records matching 1 or 2 patterns |
| - you would copy back to original file if you like the results | |
| - also drop any deleted records (x'00' last byte) | |
| in Indexed files (if the 'i' option is specified). |
| U1. | Modify filesize - truncate or extend with x'00's |
| V1. | Option 'v' - Micro Focus IDXFORMAT3 VARIABLE length Indexed records |
| V5. | IDXf3/IDXf8 file header & data header layouts |
| X1. | Option 'z' - variable length records in RDW format |
| z4 - 4 byte prefix with binary total recsize in 1st 2 (3&4 null) | |
| z2 - 2 byte prefix with binary data recsize (+2 for total recsize) |
| Y0. | Miscellaneous tips using uvhd |
| Y1. | finding Record-Size in a fixed length file |
| Y2. | using the NOT= (!) condition |
| Z1. | When your problem is too complex for 'uvhd' |
| - use 'uvcopy' which can do anything you can imagine. |
Goto: Begin this document , End this document , UVSI Home-Page
'uvhd' is a binary file investigation utility. It displays any file in vertical hexadecimal and prompts for commands to browse, search, select, update, scan/replace, print, translate, etc. uvhd is an interactive utility with a command line interface and 18 help screens.
Copyright(C) 1993-2009, UV Software Inc, distributed under GPLv3
You may download uvhd from: http://www.uvsoftware.ca/libuvhd.htm
This program is free software: you may redistribute it and/or modify it under the terms of GPLv3 (GNU General Public License version 3), as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the full description of the GNU General Public License at: http://www.gnu.org/licenses.
'uvhd' is offered as a Free sample of the Vancouver Utilties which are often used to convert mainframe JCL, COBOL,& DATA to Unix/Linux/Windows Mainframe JCL is converted to Korn shell scripts, and Mainframe COBOL is converted to Micro Focus COBOL to run under Unix/Linux.
uvhd is especially valuable to investigate mainframe type files with packed fields and no linefeeds (required by most unix/linux utilities) uvhd can investigate all converted file types: sequential, fixed, variable, indexed, text, binary, C-ISAM, D-ISAM, Micro Focus COBOL IDXFORMAT1,3,8)
uvhd displays any file in vertical hexadecimal, 64 byte segments, in 3 line groups (characters on 1st line, zones on 2nd line,& digits on 3rd line).
When you find a data problem, use the print function to capture the evidence and send it to your associates via email or hardcopy printout. Hardcopy or softcopy printouts of binary/packed files with byte position scales are not possible with most other unix utilties.
============================================================================
Owen Townsend, UV Software, 4667 Hoskins Rd., North Vancouver BC, V7K2R3
Tel: 604-980-5434 Fax: 604-980-5404
Email: owen@uvsoftware.ca Web: http://www.uvsoftware.ca
Copyright(C) 1993-2009, UV Software Inc, All rights reserved
============================================================================
Goto: Begin this document , End this document , UVSI Home-Page
| Assuming |
|
#1. cp ??/uvhd.c src/uvhd.c - copy/rename downloaded program
======================= - ensure the filename is 'uvhd.c'
#2. cc -DH64 src/uvhd.c -obin/uvhd <-- compile the program
============================== - option '-DH64' for 64 bits (-DH32 dflt)
- also add '-q64' for AIX
#3. bin/uvhd bin/uvhd - test uvhd (using uvhd itself as sample file)
================= - will display 1st 256 bytes & prompts for command
--> s 'uvhd version' <-- suggested command to search for uvhd version
--> ss <-- repeat the search for other occurrences
#4. Add bin to your PATH so you can execute it from anywhere.
PATH=$PATH:/home/users/bin; export PATH
=======================================
You may export variable UVHDROP in the .profile to specify the preferred options for each user. For example, users who prefer 1 relative scales and space 2 for displays, may wish to add the following to their .profile:
export UVHDROP=g1s2 <-- user options for 1 relative & space 2 ===================
Goto: Begin this document , End this document , UVSI Home-Page
uvhd runs in the DOS Command Prompt window under Windows 95,98,NT,2000,XP,etc.
The simplest plan is to download uvhd.exe & store it in the 'Program Files' directory so windows will find it when you type 'uvhd'.
Here is an alternative plan if you prefer to store uvhd in a separate directory. This is consistent with the documentation tutorials & Help screen examples. It is also compatible with the installation of the entire package of Vancouver Utilities for Windows/DOS (in case you later decide to purchase them).
| C:\uvwin |
|
| C:\uvwin\binDOS |
|
| C:\uvwin\dat1 |
|
| C:\uvwin\tmp |
|
#1. ControlPanel -> System -> Advanced -> Environmental Variables
#2. New or Edit (depending on whether PATH is already defined or not)
#3. PATH C:\uvwin\binDOS
======================
#1. EDIT C:\AUTOEXEC.BAT
#2. SET PATH=%PATH%;C:\uvwin\binDOS
'uvhdcob' displays COBOL copybook fieldnames with the corresponding data. See complete details in section uvhdcob.doc.
Goto: Begin this document , End this document , UVSI Home-Page
This is optional, but it is highly recommended, since it converts the default small & ugly black & white DOS window to a beautiful blue experience. The following was tested on a 17 inch monitor.
#3a. Startin --> C:\uvwin #3b. Run --> Maximized (choices: Normal, Minimized, Maximized)
#4a. Screen buffer size Width --> 120 #4b. Screen buffer size Height --> 300 #4c. Window size Width --> 112 #4d. Window size Height --> 56
#5a. Screen background --> dark blue
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd has been compiled on Windows2000 using the MSDOS command line screen. I used the lcc-win32 compiler which may be downloaded from www.cs.virginia.edu. lcc-win32 works great (thanks to Jacob Navia).
You do not need to download lcc-win32 & compile uvhd for Windows/Dos since I have already compiled it and you may download uvhd.exe from the UV Software website www.uvsoftware.ca. In case you are interested, here are procedures that could be used to compile uvhd for Windows/DOS. Please see WindowsDOS.htm#E3 for the exact procedures used at UV Software.
| D:\lcc\bin |
|
| D:\uvwin\src |
|
| D:\uvwin\cctmp |
|
| D:\uvwin\bin |
|
| D:\uvwin\dat1 |
|
#1. cd D:\uvwin
#2. copy src\uvhd.c cctmp - copy master source to cctmp for compile
#3. cd cctmp
#4. lcc -DDWIN uvhd.c - compile uvhd source to object
=================
#5. lcclnk uvhd.obj - link uvhd object to executable
===============
#6. cd ..
#7. copy cctmp\uvhd.exe binDOS - copy uvhd.exe to the binDOS subdir on WinDos
#8. uvhd dat1\custmas1 r256 - execute/test uvhd on custmas1 demo file
Goto: Begin this document , End this document , UVSI Home-Page
Note that the print command 'p' does not print immediately, but collects output (from possible multiple print commands in a uvhd session) into a tmp/file, which is subsequently printed manually after you quit uvhd.
The immediate print command 'i' uses the command stored in the variable 'prtcmd' in the uvhd.c source code.
char prtcmd[30] = "uvlp12"; /* default iprint command */ ===========================
The 'uvlp12' script is part of the Vancouver Utilities package that calls the 'uvlist' utility (has many options for cpi, landscape, etc).
If you specify option 'l' on print/iprint commands then prtcmdW is used. You would probably do this when you wish to print 100 chars per line but view the 64 chars per line on then screen.
char prtcmdW[30] = "uvlp12L"; /* default when option l on p/i cmds */ =============================
If desired, you could change these commands to use the 'lp' command directly (vs the uvlp12/uvlp12L script defaults).
char prtcmd[30] = "lp -onobanner -dlaser1"; /* specify lp vs uvlp scripts */ ===========================================
If you are running uvhd in the DOS command window of a Windows system (95,98,NT,2000,XP,etc), then the print commands default to the following:
char prtcmd[30] = "uvlpr12"; /* default iprint for Windows */ ===========================
char prtcmdW[30] = "uvlpr12L"; /* default iprint if option l on Windows */ =============================
'uvlpr12/uvlpr12L' are Windows/DOS scripts & the full names are uvlpr12.bat & uvlpr12L.bat. They are stored in subdir C:\uvwin\batDOS. These DOS batch scripts redirect output to LPT1.
'uvlp12/uvlp12L' are Unix/Linux Korn shell scripts & are stored in subdir /home/uvadm/sf/util/. These Korn shell scripts pipe output to 'lp'.
Note that uvlpr12/uvlpr12L are used when compiled for native Windows with compile variable 'DWIN'. See install guide WindowsDOS.htm for Windows (vs install.htm for Unix/Linux).
When uvhd.c is compiled for Unix/Linux emulators (SFU/UWIN/CYGWIN) that run under Windows, then uvlp12/uvlp12L unix scripts will still apply.
Goto: Begin this document , End this document , UVSI Home-Page
A more convenient method of modifying Immediate printing is to use the environmental variables 'UVLPDEST' & 'UVHDPRINT'. You could export them at your shell prompt before running uvhd or even better setup your normal choices in your .profile. Here are some examples:
export UVLPDEST=-dlaser2 <-- setup printer dest for all 'uvlp' scripts
export UVHDPRINT=uvlp12 <-- the default script uvlp12 for 64 chars Portrait
export UVHDPRINT=uvlp18 <-- could specify uvlp18 to get 128 chars Portrait
export UVHDPWIDE=uvlp12L <-- UVHDPWIDE script used when option 'l'
specified on print/iprint commands
- uvlp12L gets 100 chars on Landscape
- uvlp14L gets 128 chars on Landscape
prtcmdW or UVHDPWIDE is used if you specify the 'l' option on print/iprint commands, for example:
--> i5l100 <-- prints next 5 records, 100 chars per line
Landscape at 14 cpi to fit 11" across
--> i5l128 <-- can get up to 128 chars Landscape at 14 cpi
--> i5 <-- would default to 64 chars per line Portrait
(possibly modified by 'l' command line option)
The default scripts for printing on Windows are uvlpr12 & uvlpr12L. These are defined within the uvhd.c program & are used if no environmental variables are defined. These are equivalent to the following:
set UVHDPRINT=uvlpr12 <-- specify DOS script for 64 chars Portrait
set UVHDPWIDE=uvlpr12L <-- UVHDPWIDE script used when option 'l'
specified on print/iprint commands
For windows 2000 you could define on the following screen:
ControlPanel --> System --> Advanced --> Environmental Variables
Goto: Begin this document , End this document , UVSI Home-Page
Records are displayed 256 bytes at a time by default (if rcsz not spcfd) in 4 groups of 3 vertical hex lines as follows:
...........record in character format (. for non-dspl chars)....
...........hex representation of record zones...................
...........hex representation of record digits..................
uvhd dat1/custmas1 r256s2 - command to display the testfile ========================= options: r256=record-size, s2=double space
filename=/home/uvadm/dat1/custmas1 options=r256s2
records=32 filesize=8192 recsize=256 fsize%rsize(remainder)=0
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 ..4V|...
4442222222222442535343222233323332333322222222222222222201357000
9DF00000000002306931810000250D754D55310000000000000000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 ...............................f.....<........f.C
0000008900000000880000000018000680001300000000694222222222222222
00C0026C0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
rec#=1 rcount=32 rsize=256 fsize=8192 dat1/custmas1 null=next,r#=rec,s=search,u=update,x=rollback,p=print,i=iprint,w=write,e=count ,g=genseq#,c=checkseq#,t=translate(ta=Asc,te=Ebc,tu=Upr,tl=Lwr,tc=Chars,tp=Pers) ,R#=Recsize,h1=char,h2=hex,q=quit,?=help --> q
In this example we entered 'q' to quit after the 1st 256 bytes of the file was displayed, but we could have entered a record# or byte# to explore other areas of the file. Note that the current record# & byte# are displayed at the left of the two top lines (the 0-64 byte scale).
The uvhd display is especially useful for displaying data files that do not have line feeds & therefor are not easily displayed by an editor & for files with packed decimal fields.
Any non displayable characters is represented by periods on the character line (1st line of 3 vertical hex lines). The above sample has a lot due to the multiple packed fields.
Goto: Begin this document , End this document , UVSI Home-Page
uvhd issues a warning for Fixed record lengths that are not evenly divisible into the filesize. As of March 2003, uvhd also calculates the next lower & next higher record sizes that are evenly divisible into the filesize. It is then easy to correct the Record size via the 'R' command (which is equivalent to the 'r' option on the command line).
For example if you specified r300 for the dat1/custmas1 test file (vs the correct r256), you would get the following display:
uvhd dat1/custmas1 r300s2 <-- intentional incorrect 'r'ecord size option =========================
filename=/home/uvadm/dat1/custmas1 options=r300s2
records=27 filesize=8192 recsize=300 fsize%rsize(remainder)=92
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 ..4V|...
4442222222222442535343222233323332333322222222222222222201357000
9DF00000000002306931810000250D754D55310000000000000000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 ...............................f.....<........f.C
0000008900000000880000000018000680001300000000694222222222222222
00C0026C0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
256 132588 GEECOE GENERATOR SERVICESUNIT 170
33333322224444442444454545254554445544523332
13258800007553F5075E5214F20352693535E9401700
--> R256 <-- enter correct record-size at prompt while on 1st record
- see tip 'Y1' for more explanations
Goto: Begin this document , End this document , UVSI Home-Page
uvhd filename [options] <-- enter filename & options on command line uvhd dat1/custmas1 r256us2 <-- Example (r256=recsize,u=updates,s2=space2) ========================== - options lower case, optional numeric values
| help01 |
|
| help02 |
|
| help03 |
|
| help04 |
|
| help05 |
|
| help06 |
|
| help07 |
|
| help08 |
|
| help09 |
|
| help10 |
|
| help11 |
|
| help12 |
|
| help13 |
|
| help14 |
|
| help15 |
|
| help16 |
|
| help17 |
|
| help18 |
|
| help19 |
|
uvhd dat1/custmas1 r256us2 <-- Example (r256=recsize,u=updates,s2=space2) ==========================
a1 - translate to ASCII, character line (prior to zone & digit lines) b1 - inhibit BOLD search patterns, b2=no BOLD errmsgs, b3=both(DOS dflt) c1 - display extended ASCII chars values 128-255 (vs showing as periods) d2 - show file dsplcmnts on all segments vs only 1st segment of record e1 - no errmsg filesize/recsize not divisible, e2=no recsize calc, e3=both f# - first record# to be displayed (default #1) g0 - zero relative column scale (default), use g1 for 1 relative g1 - also use 1 relative dsplcmnts on commands (search,update,etc) h0 - auto determine display: chars only or hexadecimal (depending on data) h1/h2- h1=force characters only, h2=force hexadecimal (chars/zones/digits) l# - line display width, default 64, max 1024
Goto: Begin this document , End this document , UVSI Home-Page
| m# |
|
| n# |
|
| o# |
|
| r# |
|
| s# |
|
| t1 |
|
| t2 |
|
| u |
|
| v |
|
| w1 |
|
| z# |
|
| z2 |
|
| z4 |
|
| z8 |
|
| z1 |
|
| null |
|
| r# |
|
| b# |
|
| R# |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/custmas1 r256u - examples for demo file 'custmas1' (may download) ======================== - r256=recsize,u=update allowed
s 'LTD' - search for 'LTD' anywhere in record ss - repeat last search (starting from next record) s 0(60),'LTD' - search for 'LTD' anywhere in 1st 60 bytes s 77(2),='BC' - search for 'BC' in bytes 77-78 (match = assumed) s 77(2),!'BC' - search for Not 'BC' in bytes 77-78 s 77(2),>'BC' - search for greater than 'BC' in bytes 77-78 s 120(5),x'000000000C' - search for packed decimal zero field in 120-124 s 120(5),!x'000000000C' - search for non-zero packed field in 120-124 s 'ROAD',|,'STREET' - search for ROAD or STREET anywhere in record (|=OR) s 'ROAD',|,'STREET',|,'DRIVE' - search for 3 patterns anywhere in record s 0(1),'1',77(2),'BC' - '1' in byte 0 And 'BC' in 77-78 s 0(1),'1',|77(2),'BC' - '1' in byte 0 Or 'BC' in 77-78 s 0(1),'1',77(2),'BC',90(3),'604' - '1' in 0 And BC(77-78) And 604(90-92) s 0(1),'1',|77(2),'BC',|90(3),'604' - '1' in 0 Or BC(77-78) Or 604(90-92) s adrs1,value1,adrs2,value2,adrs3,value3 - 3 pairs of address & value - 'And' is the default when 2 or 3 conditions are specified - 'Or' is signalled by the '|' (pipe symbol)
uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#I1 ======================== - must specify option 'u' if updates intended
| s 'LTD' |
|
| sb 'LTD' |
|
| ss |
|
| sss |
|
s 77(2),'BC',242(4),>'1989',242(4),<'2000' - search for BC updated in 1990's ========================================== - search date range
s 77(2),'BC',242(4),>'1989',<'2000' - same (3rd adrs defaults to 2nd)
s 77(2),'AB',|77(2),'AL' - search for 'AB' or 'AL in 77-78 s 77(2),'AB',|,'AL' - same as above (2nd field defaults to 1st) s 77(2),'AB',|,'AL',|,'YK' - search for 'AB' Or 'AL' Or 'YK' in 77-78 s 'LTD','ROAD','BC' - searches entire record, all 3 must be found s 'LTD',|,'ROAD',|,'BC' - searches entire record, any 1 found is a match
| sn5 77(2),'BC' |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#I1 ======================== - must specify option 'u' when updates intended
| u 77(2),'AB' |
|
| x |
|
| uu |
|
| u9999 77(2),'AB' |
|
u99 77(2),'AB',77(2),'AL' - update next 99 recs with AB 77-78 if currently AL u99 77(2),'AB',,'AL' - same as above, 2nd adrs defaults to 1st u99 9(1),'*',8(1),'D',77(2),'BC' - update byte 9 '*', if 8 is 'D' & prov BC
>>> x/X - rollback last update or all updates to current rec x - rollback last update to current rec (repeat x toggles last update) X - rollback ALL updates to current rec (repeat X toggles ALL updts) x/X only for record on display & applies to both u(update) & v(scan/replace)
uvhd dat1/custmas1 r256u - demo file shown at www.uvsoftware.ca/uvhd.htm#I1 ======================== - must specify option 'u' if updates intended
u 75(1),'*',77(2),'BC' - test conditional update on 1 (current) record uu9999 - then re-execute update on ALL records via uu9999
- OR for interactive updates, use 'ss' & 'uu' interleaved
s 77(2),'BC' - 1st search to qualifying record
u 75(1),'*' - 1st update to record on display
ss - repeat last search (s 77(2),'BC')
uu - repeat last update (u 75(1),'*')
- can also use this for interleaved 'ss' & 'vv' (scan/rep)
| x |
|
| X |
|
Goto: Begin this document , End this document , UVSI Home-Page
>>> v=scan/replace - scan a record field for a search pattern
- if found replace with a specified replacement pattern
- may truncate or blank fill if search/replace pattern lengths unequal
uvhd dat1/custmas1 r256u - demo file layout at www.uvsoftware.ca/uvhd.htm#I1 ======================== - must specify option 'u' if 'v' updates intended
v 10(25),'LTD','LIMITED' - replace 'LTD' with 'LIMITED' anywhere in 10-34
v999 10(25),'LTD','LIMITED' - 'LTD' to 'LIMITED' on next 999 records (or EOF) v999 35(25),'AVE.','AVENUE',77(2),'BC' - replace only if BC in 77-78 v999 'ST.','STREET' - a big mistake for fixed length record layouts v999 0(256),'ST.','STREET' - same as this, entire record would be shifted
v999w 10(25),'LTD','LIMITED' - option 'w' to write separate file to tmp/...
- writes tmp/filename_yymmdd_hhmmssV (Text records, this field only)
uvhd tf/tabtest1 t <-- demo TEXT file with tabs (unix expands to 8 spaces) ================== - option 't' Text file, 'u' not req'd to write sep file
v999w x'09',' ' <-- replace tabs (x'09') with 4 spaces (tf/tabtest1 file)
>>> w=write - write data records only for later use (test files,etc)
- writes start at current position & end at EOF (or max count)
- write outputs written/appended to tmp/filename_yymmdd_hhmmssW
| w5 |
|
| ww |
|
| w 'VANCOUVER' |
|
| w25 77(2),'BC' |
|
w 8(1),'D',77(2),'AB',|,'AL' - write recs with 'D' in 8 & AB or AL in 77-78
| we10 |
|
| w100e5 |
|
| we10 77(2),'BC' |
|
| wi |
|
| wi 77(2),'BC' |
|
Goto: Begin this document , End this document , UVSI Home-Page
| w100r64t2 |
|
| w99z2a1c1 |
|
| a1 |
|
| c1 |
|
| n1 |
|
| n2 |
|
| r# |
|
| t1 |
|
| t2 |
|
| t3 |
|
| t4 |
|
| z# |
|
| z2 |
|
| z4 |
|
| z1 |
|
>>> p=print - write formatted records to a file for subsequent lp,uvlp,vi,etc
- writes tmp/filename_yymmdd_hhmmssP (concat for uvhd session)
- export UVLPDEST="lp -dlaserxx" for unix lp (see help17 below)
p5 - print 5 recs from current position p25 'VANCOUVER' - search & print (25 max) records with 'VANCOUVER' anywhere p 77(2),'BC' - search & print (til EOF) records with BC in bytes 77-78 p 77(2),'BC',90(3),!'604' - print recs with BC in 77-78 & Not 604 in 90-92 p9s2f3 - print 9 records, space 2, formfeed every 3rd record pp - repeat last print command (from current position)
>>> i=iprint - write formatted records to tmp file for immediate uvlp12/lp
- writes tmp/filename_yymmdd_hhmmssI & uvlp12 issued immediately
i5 - iprint 5 recs 64 char lines (dflt: export UVHDPRINT=uvlp12) ii - repeat last iprint command (from current position) i 'VANCOUVER' - iprint records with 'VANCOUVER' anywhere in record i 77(2),'AB',|,'AL' - print records with AB or AL in 77-78 i 0(120),<x'20' - iprint records with any bytes < space in 1st 120 bytes i6s2f4 - iprint 6 records, space 2, formfeed every 4th record i3s2l128 - iprint 3 recs, 128 bytes/line, using export UVHDPWIDE=uvlp14L
Goto: Begin this document , End this document , UVSI Home-Page
>>> t=translate - to ASCII,EBCDIC,UPPER,lower,characters,periods ta=Ascii, te=Ebcdic, tu=Upper, tl=lower, tc=characters, tp=periods
ta - translate to Ascii, entire current record, (t1a is same)
ta 0(120) - translate to ASCII, 1st 120 bytes of current record
ta 240(16) - translate bytes 240-255 (zero relative, 241-256 one relative)
t999999a - translate to Ascii, all records in file (from current to EOF)
te - translate to Ebcdic, entire current record
tu - translate to Upper, entire current record
tl - translate to Lower, entire current record
tc - translate to Characters, any unprintables translated to blanks
- unprintables are x'00'- x'1F' & x'7F'-x'FF'
tc1 - translate unprintable Chars to blanks, except LineFeeds x'0A'
tc2 - translate to Characters, except for Carriage-Returns x'0D'
tc4 - translate to Characters, except for FormFeeds x'0C'
tc8 - translate to Characters, except for Tabs x'09'
tc15 - translate to Chars, except LFs,CRs,FFs,Tabs (1+2+4+8=15)
tc3 - translate to Chars, except for LFs & Crs
tp - translate any unprintable Characters to carats
tp15 - translate unprintables to carats, except LFs,CRs,FFs,Tabs
t999999p1 0(120) translate all recs, unprintables to carats, except LF
>>> c=check - check sequence in specified field - until EOF or SEQUENCE ERR
| c 0(6) |
|
| cd 0(6) |
|
| ce 74(6) |
|
| ci 74(6) |
|
| ci10 74(6) |
|
| cc |
|
| g9999 75(5),'00001' |
|
gi10 72(8),'#00010.' - seqnum cols 74-79 from 000010 incrmnt by 10
- any non-numeric data is inserted before & after the seqnum digits
- might omit count 9999 to observe results in current record
gg9999 - then repeat command (gg) with count to seqnum entire file
g9999 74(6),'A00001',0(1),'A' - conditional seqnum, if col 1 = 'A' r1 - return to record #1 before next command g9999 74(6),'B00001',0(1),'B' - conditional seqnum, if col 1 = 'B'
Goto: Begin this document , End this document , UVSI Home-Page
>>> e=enumerate - count records from current point to EOF e - count records from current position to EOF
uvhd dat1/custmas1 r256 - demo file shown at www.uvsoftware.ca/uvhd.htm#I1 =======================
| e 'LTD' |
|
| e25 77(2),'BC' |
|
e99 77(2),'AB',|77(2),'AL' - count records with AB or AL in bytes 77-78
e99 77(2),'AB',|,'AL' - same as above (2nd adrs defaults to 1st)
e99 77(2),'BC',90(3),!'604' - count recs with BC in 77-78 & Not 604 in 90-92
- powerful technique to verify record data
>>>drop - copies file to tmp/fname_yyyymmdd_hhmmssD, drop matching records
a pattern & optionally with D-ISAM flag x'00' in last byte
- file overwritten if command repeated (no collection as on write)
- copy starts at current position & ends at EOF (or max count)
| d 8(1),'D' |
|
| d500i |
|
| di |
|
>>> z=truncate (modify) filesize (truncate or extend with x'00's)
| z100000 |
|
Goto: Begin this document , End this document , UVSI Home-Page
tip#1 - use command repeats to save keystrokes
- use 'double letter commands' to repeat prior cmd w/o rekeying args
ss - repeat last search, uu - repeat last update, ii - repeat last print
- 1st re-position to desired rec before executing repeat command
- or 'r1' to return to begin file to include all recs
ww5 - may specify count on repeat commands, if original was 'w5 0(1),'A''
ww5 would write next 5 recs with A in 1st byte (bypassing non 'A's)
| tip#2 |
|
s 77(2),'BC',242(4),>'1997' - search for BC records newer than 1997
w=s - transfer Search args to Write command
ww99999 - Write out selected records until EOF
- transfer also applies to Enumerate(e=s), Print(p=s),& Iprint(i=s)
tip#3 - using NOT '!' condition, can use to find exceptions to most records
- for example to find any provice codes that are NOT 'BC'
s 77(2),!'BC' <-- display records with province codes NOT = 'BC'
w9999 77(2),!'BC' <-- write NON 'BC' records to tmp/filename_date_time
export UVHDROP=s2z1 <-- user preference options example
s2=space2, g1=one relative byte#s (vs 0 rel default)
export UVLPDEST=-dlaserxx <-- specify printer destination for 'i' command
export UVHDPRINT=uvlp12 <-- specify iprint script for 64 char lines
- uvlp12 is UV script for laser Portrait printing
export UVHDPWIDE=uvlp12L <-- recommended script for Landscape 100+ chars
- UVHDPWIDE used if you specify 'il100'
export UVHDPRINT="lp -dlaserxx" <-- may specify standard unix lp command
export UVHDPWIDE="lp -dlaserxx -onobanner" - for 64 chars or 100 chars
uvhd version 20090207 - Copyright UV Software Inc. 1993-2009 - see full documentation at: www.uvsoftware.ca/libuvhd.htm
Goto: Begin this document , End this document , UVSI Home-Page
'uvhd' is a binary file investigation utility. It displays any file in vertical hexadecimal and prompts for commands to browse, search, select, update, scan/replace, print, translate, etc. uvhd is an interactive utility with a command line interface and 17 help screens.
Copyright(C) 1993-2009, Owen Townsend, UV Software, owen@uvsoftware.ca
This program is free software: you may redistribute it and/or modify it under the terms of GPLv3 (GNU General Public License version 3), as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the full description of the GNU General Public License at: http://www.gnu.org/licenses.
Goto: Begin this document , End this document , UVSI Home-Page
uvhd filename [options] - display the named file on the screen ======================= in 64 byte lines (see display format above)
Options must follow the filename as 1 string of alpha & numeric values. If omitted, option 'r' record size defaults to 256
uvhd dat1/custmas0 r256a1s3 <-- example showing multiple options =========================== - recsize, Ascii translate, space lines
| a |
|
| b1 |
|
| b |
|
| c1 |
|
| d2 |
|
| e1 |
|
| f# |
|
| g0 |
|
| g1 |
|
| h0 |
|
| h1 |
|
| h2 |
|
| l99 |
|
Goto: Begin this document , End this document , UVSI Home-Page
| m# |
|
| n# |
|
| o# |
|
| r9999 |
|
| s# |
|
| s1 |
|
| s2 |
|
| s4 |
|
| s3 |
|
| s7 |
|
| t |
|
| t1 |
|
| t2 |
|
| t3 |
|
| u |
|
| v# |
|
| w1 |
|
| v |
|
| z4 |
|
| z2 |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/custmas1 r256 - display the file as 256 byte records (default)
uvhd file r128aus2g1 - may concatenate all options
uvhd file r128,a,u,s2,g1 - or may separate with commas if desired
r128 - recsize=128
a - translate character line to ASCII (for EBCDIC files)
- constants on commands will be translated to EBCDIC
u - allow update commands to be used
s2 - space between 3 line segments (chars/zones/digits)
g1 - use 1 relative column scale (vs zero relative)
- also expects you to enter 1 relative displacements
on the commands (search, update, etc)
| uvhd file r100l50 |
|
| uvhd file t2 |
|
export UVHDROP=g1 <-- force 'g1' on all subsequent uvhd commands
Note that you could still override this on the command line
uvhd file r256g0 <-- 'g0' on command line overrides UVHDROP=g1
Goto: Begin this document , End this document , UVSI Home-Page
| null |
|
| r# |
|
| b# |
|
+# - go specified # of records ahead from current position -# - go specified # of records back from current position
| R# |
|
| s |
|
| u |
|
| v |
|
| p |
|
| i |
|
| w |
|
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
| d |
|
| c |
|
| e |
|
| t |
|
Goto: Begin this document , End this document , UVSI Home-Page
| I1. | Browse - display records consecutively |
| - jump to & display any record in the file by record# |
| J1. | Search - search by pattern, anywhere in the record (by default) |
| or within specified column locations | |
| - may search on 1 or 2 fields with AND/OR relationships | |
| - match data =,>,< equal(default), greater than, less than | |
| - repeat previous search via 'ss' (vs 's' + search args) | |
| J2. | Search Indexed files for deleted records |
| K1. | Update - update the current record on display |
| - specified columns replaced with specified data (char/hex) | |
| - option to rollback current record updates | |
| - option for multi-record updates with 1 qualifier field |
| L1. | Scan/Replace - searches the specified record field, searching for a pattern |
| - if found, replace with a replacement pattern. | |
| - will truncate or blank fill if search & replace lengths different |
| M1. | Write - write Unformatted records to a file: tmp/fname.yymmddhhmmW |
| for subsequent use as test files, etc. | |
| - may specify number of records from current position | |
| or records matching 1 or 2 patterns within specified columns |
| N1. | Print - write formatted records to tmp file for later lp,uvlp,etc |
| - output file will be: tmp/filename.yymmddhhmmP | |
| - may specify a number of records from current position | |
| - may specify records matching 1 or 2 patterns & a max count | |
| - To actually print, you must quit uvhd & select the desired | |
| filename from the tmp directory. |
| O1. | Iprint - write formatted records to a file for immediate printing |
| via the 'uvlp' command (see uvlist.doc). | |
| - may specify number of records &/or records matching patterns |
| P1. | Generate Sequence Numbers |
| - may specify starting number & increment (default 1) | |
| - may specify constants before & after sequence# |
| Q1. | Check - check sequence of specified field |
| - options for ascending, descending, duplicates |
| R1. | Enumerate - count records from current position matching 1 or 2 |
| specified patterns until EOF or within a max record count |
| S1. | Translate - to Ascii, Ebcdic, Upper, Lower, Characters, Periods |
| - unprintable characters can be translated to blanks or Periods |
| T1. | Drop - copy to tmp file, dropping records matching 1 or 2 patterns |
| - you would copy back to original file if you like the results | |
| - also drop any deleted records (x'00' last byte) | |
| in Indexed files (if the 'i' option is specified). |
| U1. | Modify filesize - truncate or extend with x'00's |
Goto: Begin this document , End this document , UVSI Home-Page
If you have installed the full Vancouver Utilities package, you will have the testfile in the /home/uvadm/dat1 subdirectory.
#1. cd /home/????? - change to your home directory
#2. mkdir dat1 tmp - make directories for testfile & print outputs
#3. cp /home/uvadm/dat1/custmas1 dat1 - copy supplied file to your sub dir
#4. uvhd dat1/custmas1 r256 - execute uvhd (interactive utility)
=======================
| Note |
|
#1. http://www.uvsoftware.ca - goto UV Software web site
========================
#2. custmas1.dat - click on testfile name to download
============ - save to disc
#3. mv custmas1.dat /home/userx/dat1/custmas1
=========================================
- move testfile to your home dir & drop suffix (.dat)
to match tutorial (shorter & easier to key)
- '.dat' on web site necessary to download as binary
& preserve the packed fields
#4. uvhd dat1/custmas1 r256 - execute uvhd (interactive utility)
=======================
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/custmas1 r256s2 <-- initiate uvhd on test file with options
========================= 'r256' (record-size) & 's2' (double space)
(between 3 line groups of chars,zones,digits)
filename=/home/uvadm/dat1/custmas1 options=r256s2
records=32 filesize=8192 recsize=256 fsize%rsize(remainder)=0
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 LARRY WRENCH ..4V|...
4442222222222442535343222233323332333324455525544442222201357000
9DF00000000002306931810000250D754D55310C12290725E38000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 .E|...V}.......................f.....<........f.C 19950531
0470005700000000880000000018000680001300000000694233333333222222
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
rec#=1 rcount=32 rsize=256 fsize=8192 dat1/custmas1
null=next,r#=rec,s=search,u=update,x=rollback,p=print,i=iprint,w=write,e=count
,g=genseq#,c=chkseq#,t=translate(ta=Asc,te=Ebc,tu=Upr,tl=Lwr,tc=Chars,tp=Pers)
,R#=Recsize,h1=char,h2=hex,q=quit,?=help -->
uvhd displays the 1st record & waits for you to enter a command. Null entries cause uvhd to display records consecutively. You can jump to & display any record in the file by entering the desired record#.
#1. null entry - display next consecutive record
==========
#2. r10 - display record #10
===
#3. r99999 - go to End Of File
======
#4. -1 - backup to & display last record in file
==
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/custmas0 r256 <-- investigate EBCDIC demo file (dat1/custmas0) =======================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ......@@@@.........@......@...K@@@@....@.....@....@@@@@@@@@@....
FFFFFF4444CECDCDCCD4DDEDDE4DEC44444FFFF4CDECD4DDCC4444444444DCDC
130140000055597955504636920334B000018150266550961400000000005151
64 ...@@@@@@@@@@..@......@@@@...`...`....@@@@@@@@@@@@@@@@@@........
CDD4444444444CC4EFEFCF4444FFF6FFF6FFFF44444444444444444400000000
946000000000023059218100006040754055310000000000000000000000C000
128 .........W0....`........)X|..f3.....\.......................f...
0000000005300016000000002570063100095000000000000000000000016000
0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
192 .E|...V}.......................f.....<........f..@@@@@@@@@@@@@@@
047000570000000088000000001800068000130000000069C444444444444444
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
BUT, of course we can NOT read the data on unix/linux ASCII systems. 'uvhd' provides option 'a' to perform EBCDIC to ASCII translation on the character line of the 64 byte 3 line groups (characters, zones, digits). You can then 'read' the EBCDIC data. Note that the zones & digit lines will reflect the actual data values (see an EBCDIC code card).
uvhd dat1/custmas0 r256a <-- investigate EBCDIC demo file, using option 'a' ======================== to translate the character lines to ASCII
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
FFFFFF4444CECDCDCCD4DDEDDE4DEC44444FFFF4CDECD4DDCC4444444444DCDC
130140000055597955504636920334B000018150266550961400000000005151
64 IMO BC V9S1H1 604-754-5531 ........
CDD4444444444CC4EFEFCF4444FFF6FFF6FFFF44444444444444444400000000
946000000000023059218100006040754055310000000000000000000000C000
128 .........W.....-.........X@..f.....m*.......................f...
0000000005300016000000002570063100095000000000000000000000016000
0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
192 .E@...V'........c..............f..............f.C
047000570000000088000000001800068000130000000069C444444444444444
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
Goto: Begin this document , End this document , UVSI Home-Page
Note that there are 24 * 5 byte packed fields in 120-240. You can identify the end of each packed field by the sign, x'_C' or x'_D'in the last byte. For example here is the 1st 8 bytes of last segment:
192 .E@...V' <-- character line
04700057 <-- zones line
35C0046D <-- digits line
^ ^ <-- '^' marks sign/end of each packed field
Translation would destroy packed fields, so we will use our options to specify translation only for 0-119 & 241-255 (see options c0d120e240f16 on the command line below).
Option 'a' is relevant to sites that are converting from an IBM mainframe to Unix, Linux, or Windows/SFU. The data files are transferred to the new machine where they are converted from EBCDIC to ASCII (see DATAcnv1.htm).
The conversion jobs are generated automatically from the COBOL copybooks. All character type & unpacked numeric fields are translated from EBCDIC to ASCII, while preserving any packed or binary fields unchanged (since they would be destroyed by the translation).
'uvhd' with option 'a' is a vital asset to verify the data conversions, you can spot check the conversion by examining both the input EBCDIC data & the output ASCII file.
Goto: Begin this document , End this document , UVSI Home-Page
You can search for & display records containing a specified pattern. The pattern may be anywhere in the record (by default) or within specified column locations.
Searching is performed from the current record on display until EOF, so you may need to return to the begining of file (command 'r0') to ensure you find all records.
uvhd dat1/custmas1 r256 - initiate uvhd ======================= - display 1st record & wait for oprtr command
#1. s 0(120),'CALGARY' - search for 1st record concatenating 'CALGARY' # ================== (within 1st 120 bytes of each record)
***found CALGARY at byte# 60
r# 23 1 2 3 4 5 6 b# 5632 0123456789012345678901234567890123456789012345678901234567890123
0 306959 356582 ALBERTA LTD. DEVITT NURSERY CALG
3333332222333333244445542454222222244545524555455222222222224444
306959000035658201C252410C44E0000004569440E5235290000000000031C7
64 ARY AL T2T5N1 - - ........
4552222222222442535343222222222222222222222222222222222200000000
12900000000001C04245E10000000D000D00000000000000000000000000C000
128 ..........)....`................................................
0000000001280006000000000000000000000000000000000000000000000000
0C0000C0009C0030C0000C0000C0000C0000C0000C0000C0000C0000C0000C00
192 ..........&Rl..................'l...I\..........C 870807
0000000000256000000000000000001260004500000000004222333333222222
00C0000C0062C0000C0000C0000C0027C0029C0000C0000C3000870807000000
#2. ss - repeat search for next record with 'CALGARY'
== (using last specified search criteria)
- repeat the 'CALGARY' search until EOF reached
#3. r0 - return to 1st record in the file
#4. s <x'20' - search for any byte < x'20' (space character)
======== - could specify as: s <' '
#5. s 'LTD','ROAD' - search for records with 'LTD' AND 'ROAD' anywhere
#6. sb 'LTD',|,'ROAD' - search BACKWARD for records with 'LTD' OR 'ROAD'
#7. ssb - repeat last search BACKWARD (vs default forward)
#8. s 77(2),>'AA',,<'AZ' - search for recs with cols 78-79 from AB to AY
Goto: Begin this document , End this document , UVSI Home-Page
This applies to D-ISAM Indexed files which are compatible with C-ISAM and Micro Focus COBOL IDXFORMAT1 files. First we need an Indexed file for our test/demo. If you have the Vancouver Utility package you can use the supplied D-ISAM file in subdir dat1/. Note that D-ISAM files are in 2 parts: data & indexed, with extensions '.dat' & '.idx'.
dat1/custmast.dat <-- data partition of indexed file ================= dat1/custmast.idx <-- index partition of indexed file =================
We will only be interested in data partition (where our data records are) since the .idx partition is unintelligible to most of us. The data partition is quite simple. All that happens when we load an indexed file from a sequential file is that 1 extra bye is added to each record. The extra byte will initially be x'0A' (LineFeed), but programs may delete records which change the x'0A' to a x'00' (null).
uvhd dat1/custmast.dat r257 <-- examine D-ISAM file with uvhd =========================== (recsize 1 extra for ISAM files)
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 LARRY WRENCH ..4V|...
4442222222222442535343222233323332333324455525544442222201357000
9DF00000000002306931810000250D754D55310C12290725E38000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 .E|...V}.......................f.....<........f.C 19950531
0470005700000000880000000018000680001300000000694233333333222222
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
256 .
0 <-- note x'0A' in byte 256, zero relative, 257 one relative
A - x'0A' IDs a good record, x'00' IDs a deleted record
s 256(1),x'00' <-- search for 1st deleted record ============== ss <-- repeat search for next deleted record ==
1 <-- return to begining of file =
t 256(1),x'00' <-- enumerate (count) no of deleted records in the file ==============
If you have a lot of indexed records, you can use 'uvsort' to sort the data partition (making it more efficient) & drop the deleted records. See uvsort.htm#L2 & uvsort.htm#M1 (to recover corrupted files).
Goto: Begin this document , End this document , UVSI Home-Page
The 'u' command will update the current record on display. You can replace specified columns with specified data (character or hexadecimal).
This is a safe method of updating Micro Focus Indexed files, because uvhd will never change the record size. Micro Focus Indexed files can be updated with 'vi' but this is very dangerous, because it is easy (with vi) to add a byte or drop a byte, which would destroy the integrity of the remainder of the file (fixed record slots, not variable text).
cp dat1/custmas1 tmp/cm1 - copy test file to tmp, since update will modify ========================
uvhd tmp/cm1 r256u - initiate uvhd ================== - 'u' option require when update intended
#1. u 14(5),'red ' - change 'EVERGREEN MOTORS'
=============== to 'EVERred MOTORS'
#2. x - undo (rollback) the last update
= - repeat to re-apply last update (toggle)
#3. u 192(3),=x'12345C' - update 1 of the packed fields
=================== (using hexadecimal notation)
r# 1 1 2 3 4 5 6
b# 0 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERred MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454554422244545524542222233332445442544422222222224444
13014000005652254000DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 604-754-5531 ........
4442222222222442535343222233323332333322222222222222222200000000
9DF00000000002306931810000604D754D55310000000000000000000000C000
128 .........W0....`........)X|..f3.....\.......................f...
0000000005300016000000002570063100095000000000000000000000016000
0C0000C0270C0540C0000C0098C0263C0444C0000C0000C0000C0000C0056C00
192 .4\...V}.......................f.....<........f.C
1350005700000000880000000018000680001300000000694222222222222222
24C0046D0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
^^^ - note results of: u 192(3),x'12345C'
& of: u 14(5),'red '
4a. r0 - reset file pointer to rec #0 (1st in file)
4b. u99 77(2),'AB',77(2),'AL' - update cols 78-79 to 'AB' if currently 'AL'
(no rollback for multi-record updates)
Note - To ensure multi-record updates to EOF, specify 'u' + a number,
that is higher than the number of records in the file.
- OK to use 9 '9's (u999999999), but do not use more (32 bit limit).
Goto: Begin this document , End this document , UVSI Home-Page
'v' (scan/replace) searches the specified record field, searching for a specified pattern & if found, replacing with a specified replacement pattern.
cp dat1/custmas1 tmp/cm1 - copy test file to tmp (since scan/rep modifies) ========================
#1. uvhd dat1/custmas1 r256u - initiate uvhd
======================== - option u required for update or scan/replace
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 LARRY WRENCH ..4V|...
4442222222222442535343222233323332333324455525544442222201357000
9DF00000000002306931810000250D754D55310C12290725E38000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 .E|...V}.......................f.....<........f.C 19950531
0470005700000000880000000018000680001300000000694233333333222222
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
#2. v 10(25),'LTD.','LIMITED' - replace 'LTD' with 'LIMITED' anywhere in 10-34
=========================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LIMITED 1815 BOWEN ROAD NANA
3333332222454545444244545524444544233332445442544422222222224444
130140000056527255E0DF4F230C9D94540181502F75E02F140000000000E1E1
| Note |
|
#3a. 5 - goto record #5 (also known to contain 'LTD.')
#3b. vv - repeat last 'v' scan/replace command
===
#4a. 1 - return to rec#1
#4b. v99 10(25),'LTD.','LIMITED' <-- same change on 99 (all) records (or EOF)
===========================
#5a. 1 - return to rec#1
#5b. v999 'LTD.','LIMITED' - big mistake for fixed length record layouts
- defaults to entire record
#5c. v999 0(256),'LTD.','LIMITED' - same as this, entire record would be shifted
Goto: Begin this document , End this document , UVSI Home-Page
tmp/filename_yymmdd_hhmmssV
===========================
Goto: Begin this document , End this document , UVSI Home-Page
Scan/Replace with different pattern lengths is a very powerful & useful feature for 'TEXT files', which we will demonstrate on the next page.
But 1st we will illustrate that it could be used for 1 selected field from a 'Fixed Length Record file' (vs scan/replace on multi-fields or entire record which would corrupt the records by pushing data into following fields).
On page 'L1' we could lose data by replacing 'LTD.' with 'LIMITED' in 10(25). Option 'w' will extract the specified field to a separate TEXT file, which allows records longer than the 25 byte original name field.
#1. uvhd dat1/custmas1 r256 - initiate uvhd
=======================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 250-754-5531 LARRY WRENCH ..4V|...
4442222222222442535343222233323332333324455525544442222201357000
9DF00000000002306931810000250D754D55310C12290725E38000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 .E|...V}.......................f.....<........f.C 19950531
0470005700000000880000000018000680001300000000694233333333222222
35C0046D0000C0023C0000C0083C0056D0012C0000C0016D3019950531000000
#2. v999w 10(25),'LTD.','LIMITED' - option 'w' to write separate file to tmp/...
============================
- writes tmp/filename_yymmdd_hhmmssV (Text records, this field only)
- text records have LineFeed inserted after last non-blank
#3. q <-- quit uvhd
#4. cat tmp/custmas1_yymmdd_hhmmssV <-- display extracted field
===============================
EVERGREEN MOTORS LIMITED
GEECOE GENERATOR SERVICES
E&L TRUCKING
NICHOLSON CHEVROLET LIMITED
OTTO MOBILES WESTERN LIMITED
We are showing only 5 of the 32 text files written, And you can see that replacing 'LTD.' with 'LIMITED' has exceeded the 25 byte original field length in some cases.
Goto: Begin this document , End this document , UVSI Home-Page
Scan/Replace with option 'w' can be very useful for TEXT files (vs fixed record fixed field demo above). For example we can use scan/replace with option 'w' to convert all tabs (x'09') in a text file to 4 spaces (vs 8 default).
The following 11 line file is supplied in /home/uvadm/tf/tabtest1 to demo uvhd scan/replace option 'w' to write a separate file, allowing longer replacements to expand the record lengths (not possible with fixed record updates in place).
# tabtest1 - test file for uvcopy job tabfix1 (replace tabs with 4 blanks)
# - 'vi' or 'lp' will expand the tabs when you examine this file
# - the 2nd last line below has 1 tab between words & without expansion would
# appear as follows (using commas to represent the tabs):
a,bb,ccc,dddd,eeeee,ffffff,ggggggg <-- see below 'commas' replaced by 'tabs'
1 2 3 4 5
0123456789012345678901234567890123456789012345678901234
=======================================================
a bb ccc dddd eeeee ffffff ggggggg <-- tab x'09' delimited
=======================================================
#1. uvhd tf/tabtest1 t <-- demo TEXT file with tabs (unix expands to 8 spaces)
================== - option 't' Text file, 'u' not req'd to write sep file
- just rec#11 shown (with tabs x'09')
10 20 30 40 50 60
r# 10 0123456789012345678901234567890123456789012345678901234567890123
534 a.bb.ccc.dddd.eeeee.ffffff.ggggggg.<-- tab x'09' delimited.
60660666066660666660666666066666660322276627233226666667660
19229333944449555559666666977777779CDD0412087097045C9D9454A
#2. v999w x'09',' ' <-- replace tabs (x'09') with 4 spaces
==================
#3. uvhd tmp/tabtest1_080517_195200V t <-- examine output file
================================== - note tabs expanded to 4 blanks
10 20 30 40 50 60
r# 10 0123456789012345678901234567890123456789012345678901234567890123
529 a bb ccc dddd eeeee ffffff ggggggg <-- tab
6222266222266622226666222266666222266666622226666666222232227662
10000220000333000044440000555550000666666000077777770000CDD04120
64 x'09' delimited.
7233226666667660
87097045C9D9454A
Goto: Begin this document , End this document , UVSI Home-Page
The 'w' command writes Unformatted records to a file for test files, etc. You may specify a number of records from the current position or records matching a specified pattern. This is an easy way to select specified records from a file & insert LineFeeds to allow printing (of mainframe type files).
uvhd dat1/custmas1 r256 <-- initiate uvhd =======================
#1. w5r80t2 <-- write 2 records from current position
======= - option 'r80' Record-size for output records
- option 't2' insert lineFeed in last byte
(so we can use vi,uvlp12,etc on output file)
>>> 5 recs written to tmp/custmas1_961116_104901W
#2. w 77(2),'AB',|,'AL' - write(select) recs with 'AB' or 'AL' cols 78-79
=================== (from current position until EOF)
>>> 3 recs written to tmp/custmas1_961116_104901W
#3. q - quit uvhd
#4. ls -l tmp - investigate the output filename assigned
-rw-rw-r-- 1 uvu group 8192 Nov 16 10:40 custmas1 -rw-rw-r-- 1 uvu group 5331 Nov 16 10:47 custmas1_961116_104600P -rw-rw-r-- 1 uvu group 400 Nov 16 10:49 custmas1_961116_104901W
#5. vi tmp/custmas1*P - use vi to inspect the file contents
130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANAIMO BC 132588 GEECOE GENERATOR SERVICESUNIT 170 - 2851 SIMPSON RICHMOND BC 208060 E&L TRUCKING LAND & CATTLE LTD WARBURG AB 211140 D FORD NEW HOLLAND BOX 1, 440 ELLIS ROAD WINTERBURN AL
#6a. we10 - write every 10th record
====
#6b. we4 77(2),'BC' - write every 4th record with 'BC' in cols 78-79
==============
Goto: Begin this document , End this document , UVSI Home-Page
| a1 |
|
| c1 |
|
| n1 |
|
| n2 |
|
| r# |
|
| t1 |
|
| t2 |
|
| t3 |
|
| t4 |
|
| Note |
|
| z# |
|
| z2 |
|
| z4 |
|
| z1 |
|
Goto: Begin this document , End this document , UVSI Home-Page
The 'p' command writes formatted records to a file for subsequent printing via lp, uvlp, etc. You may specify a number of records from the current position, or records matching a specified pattern (up to a maximum number). The 'p' command creates a file in the 'tmp' subdir of the current directory (the 'tmp' subdir will be created if it does not already exist).
filename assigned: tmp/inputfilename.yymmddhhmmP
for example: tmp/custmas1_961116_095502P
uvhd dat1/custmas1 r256 - initiate uvhd =======================
#1. p2 - print 2 records from the current position
==
>>> 2 recs printed to tmp/custmas1_961116_104604P
#2. p 77(2),'AB' - print records with 'AB' in columns 78-79
============ ('AB' is the province code for 'ALBERTA')
>>> 3 recs printed to tmp/custmas1_961116_104604P
#3. p3 0(6),>'200000' - print 1st 3 records with 1st 6 bytes > 200000
#4. q - quit uvhd
=
#5. ls -l tmp - investigate the output filename assigned
=========
-rw-rw-r-- 1 uvu group 8192 Nov 16 10:40 custmas1 -rw-rw-r-- 1 uvu group 5331 Nov 16 10:47 custmas1_961116_104604P
#6. lp tmp/custmas1*P - print the output file
================= (same display as original uvhd)
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
The 'i' command writes formatted records to a file for Immediate printing via the 'uvlp12' script (issued by uvhd using the 'system' shell command). This script is documented in uvlist.doc & is stored at /home/uvadm/sf/uvlp12. If desired you may modify the uvhd program to replace the 'uvlp12' script with the UNIX 'lp' or whatever print command you desire.
The 'i' command creates a file in the 'tmp' subdirectory & the executes the uvlp12 (or lp) for example:
format: uvlp12 tmp/inputfilename.yymmddhhmmI
example: uvlp12 tmp/custmas1_970110_154905I
You may specify a number of records from the current position, or records matching a specified pattern (optionally within specified columns).
uvhd dat1/custmas1 r256 - initiate uvhd =======================
#1. i2 - Iprint 2 records from the current position
==
>>> 2 recs printed to tmp/custmas1_970110_160006I
#2. i5 77(2),!'BC' - print (5 recs max) searching from current position
============== for records with province codes NOT= 'BC'
>>> 5 recs printed to tmp/custmas1_970110_160006I
#3. q - quit uvhd
=
The uvhd program uses the 'system' command to execute the 'uvlp' shell script (see uvlp documented in uvlist.doc). If required you could change the command by editing the program & recompiling, or via environmental variables. This was discussed early in this documentation but briefly:
export UVLPDEST=-dlaser2 <-- setup printer dest for all 'uvlp' scripts
export UVHDPRINT=uvlp <-- the default uvlp script
export UVHDPRINT=uvlp12L <-- use this to print 100 char lines Landscape
'uvlp12L' is recommended if you use the 'l100' option on your iprint commands, for example:
--> i5l100 <-- prints next 5 records, 100 chars per line
Landscape at 12 cpi to fit 11" across
--> i5 <-- would default to 64 chars per line
(possibly modified by 'l' command line option)
Goto: Begin this document , End this document , UVSI Home-Page
command 'g' generates sequence numbers. You can specify a starting value and an increment (other than the default 1). You can also specify constants to be inserted before & after the initial value (for the 1st record).
| Note |
|
#1. cp dat1/test100 tmp <-- copy a test file to tmp subdir
=================== - test100 has 100 * 40 byte records
#2. uvhd tmp/test100 r40u <-- start uvhd specifying filename,
===================== record size & update option
a. --> g10 30(4),'0001' <-- sequence# 1st 10 records
================ - insert seq# in bytes 30-33
- initial value 0001, increment by 1 (default)
0001 tf/test100 one 0001
0002 tf/test100 two 0002
- - - etc - - -
0009 tf/test100 nine 0009
0010 tf/test100 ten 0010
b. --> r1 <-- return to rec #1 (begin file)
c. --> g10i10 30(6),'#0010.' <-- sequence# 1st 10 records
==================== - inserts seq# in bytes 31-34
- inserts '#' prior & '.' after seq#
- increments by 10 (option 'i10')
0001 tf/test100 one #0010.
0002 tf/test100 two #0011.
- - - etc - - -
0009 tf/test100 nine #0018.
0010 tf/test100 ten #0019.
d. --> r1 <-- return to rec #1 (begin file)
e. --> g100 30(4),'0020',0(3),'002' <-- sequence# up to 100 records max
============================ - insert seq# in bytes 30-33
- qualified, only records that have '002' in 1st 3 bytes (twenties)
- initial value 0020, increment by 1 (default)
0001 tf/test100 one
- - - etc - - -
0019 tf/test100 nineteen
0020 tf/test100 twenty 0020
0021 tf/test100 twenty one 0021
- - - etc - - -
0028 tf/test100 twenty eight 0028
0029 tf/test100 twenty nine 0029
0030 tf/test100 thirty
- - - etc - - -
0100 tf/test100 one hundred
Goto: Begin this document , End this document , UVSI Home-Page
The 'c' command checks the sequence on a specified field & displays the first record not in sequence (or EOF all OK). You may specify option 'd' for descending (vs default ascending), option 'e' to consider equal fields to be out of sequence, or option 'i' to check the increment (i1,i10,etc).
For this tutorial, we will use 'g' (generate seq#s) to create a test file, then 'u' to create an intentional error, then 'c' to check the sequence.
#1. cp dat1/test100 tmp <-- copy a test file to a tmp subdir
===================
#2. uvhd tmp/test100 r40uh2 <-- start uvhd, specifying the filename,
======================= record size 'r40', update option 'u',
& option 'h2' to force hex display
a. --> g100i10 30(4),'0010' <-- insert seq#s in cols 31-34, incrmnt 10
====================
b. --> r51 <-- goto record #51
===
c. --> u 30(4),'0515' <-- change seq# to '0515' (from '0510')
==============
d. --> r1 <-- reposition to rec#1 (begin file)
==
e. --> c 30(4) <-- check sequence --> will be OK
=======
f. --> ci10 30(4) <-- check sequence increment 10
========== - will get error as follows:
10 20 30 40 50 60
r# 51 0123456789012345678901234567890123456789012345678901234567890123
2000 0051 tf/test100 fifty one 0515 .
3333276276773332666772666222223333222220
0051046F45341000696490FE500000051500000A
ci10 30(4) ERROR, 1st out of sequence record above
g. --> cc <-- continue sequence checking
== - will get a 2nd error (not shown)
h. --> cc <-- continue sequence checking
== - will now get to EOF (rec#100) OK
Goto: Begin this document , End this document , UVSI Home-Page
The 'e' command counts (enumerates) records from current position, matching 1 or 2 specified patterns, until EOF or within a specified maximum record count.
uvhd dat1/custmas1 r256 - initiate uvhd =======================
#1. e 77(2),'AB' - count records with 'AB' in cols 78-79
============
#2a. r0 - return to begining of file
#2b. e 77(2),'AB',|,'AL' - count records with 'AB' OR 'AL' in cols 78-79
==================
#3a. r0
#3b. e 77(2),'BC','LTD' - count records with 'BC' in 78-79
================== & 'LTD' anywhere in record
#4. e 77(2),'BC',0(256),'LTD' - same as above
=========================
#5. e 77(2),'BC',,'LTD' - WRONG (would be interpreted same as below)
===================
e 77(2),'BC',77(2),'LTD' - op3 omitted would be same as this (WRONG)
========================
--> q <-- quit dat1/custmas1
uvhd dat1/custmast.dat r257 - investigate a D-ISAM demo file =========================== (recsize 257 bytes)
#6. e 256(1),x'00' - count records with x'00' in byte 256
==============
Goto: Begin this document , End this document , UVSI Home-Page
The 't' command will translate to Ascii,Ebcdic,Upper,Lower,Characters,or Periods (depending on options a,e,u,l,c,p).
| ta |
|
| t999999e |
|
| tl 0(120) |
|
| tc1 |
|
| tc15 |
|
cp dat1/custmas1 tmp/cm1 - copy test file to tmp subdir ======================== (since we will modify)
uvhd tmp/cm1 r256u - initiate uvhd ================== - option 'u' required to modify records
#1a. te 0(120) - translate 1st 120 bytes of 1st record to Ebcdic
=========
#1b. ta 0(120) - translate 1st 120 bytes of 1st record back to Ascii
=========
#2a. t99l 10(25) - translate bytes 10-34 of all(32) records to Lower case
===========
| Note |
|
#2b. 1 - reset file pointer back to record #1
#2c. t99u 0(120) - translate 1st 120 of all(32) records to Upper case
===========
#2d. 1 - reset file pointer back to record #1
#3a. tc - translate any unprintable Chars to blanks
=== (entire current record)
#3b. x - rollback current record (undo translate above)
===
#4a. tc4 - translate any unprintable Chars to blanks
=== (except for FormFeeds x'0C')
#3b. x - rollback current record (undo translate above)
===
Goto: Begin this document , End this document , UVSI Home-Page
We will show you how you can use uvhd to translate 1 field (or all fields) in all (or some) records of a data file. We will use test/demo file /home/uvadm/dat1/custmas6, which has 32 records, but we will show only the 1st 3 & last 3, before & after the translate.
130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANAIMO BC
132588 GEECOE GENERATOR SERVICESUNIT 170 - 2851 SIMPSON RICHMOND BC
139923 JOHNSTONE BOILER & TANKS 1250 EAST PENDER STREET VANCOUVER BC
- - - 1st 3 & last 3 of 32 records - - -
402875 HULL, DON & SONS LTD. BOX 1297 PRINCE GEORGE BC
403887 D MILNER, LARRY BOX 28 RAU ROAD R.R.8 QUESNEL BC
406082 PRECAM RENTALS LTD: 10116-94TH AVE FORT ST. JOHN BC
#1. cp dat1/custmas6 tmp/cm6 <-- copy/rename test file to tmp subdir
======================== - do NOT update any files in dat1/... dir
#2. uvhd tmp/cm6 r80u <-- run uvhd on N&A 80 byte records with Update intent
================= - need option 'u' for any update command
- shows 1st record (usual uvhd behavior)
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
64 IMO BC.
#3. --> t99l 10(25) <-- translate to Lower case bytes 10-34 of all/32 records
=========== - '99' or any high number to process all records
- option 'l' specifies 'l'ower case translate
- could omit 10(25) to translate entire record
#4. more tmp/cm6 <-- display records after translate to lower case
============
130140 evergreen motors ltd. 1815 BOWEN ROAD NANAIMO BC
132588 geecoe generator servicesUNIT 170 - 2851 SIMPSON RICHMOND BC
139923 johnstone boiler & tanks 1250 EAST PENDER STREET VANCOUVER BC
- - - 1st 3 & last 3 of 32 records - - -
402875 hull, don & sons ltd. BOX 1297 PRINCE GEORGE BC
403887 D milner, larry BOX 28 RAU ROAD R.R.8 QUESNEL BC
406082 precam rentals ltd: 10116-94TH AVE FORT ST. JOHN BC
Goto: Begin this document , End this document , UVSI Home-Page
The 'd' command copies to a temporary file, dropping records via a specified pattern. The output file is written to 'tmp/filename_yymmdd_hhmmssD' in the current working directory.
If you like the results, you would copy back & rename to original file (dropping the date/time & 'D' ID automatically appended by uvhd).
If option 'i' (for IDXFORMAT1/C-ISAM files) is specified, any deleted records will be dropped. The ISAM delete flag is a x'00' in the last byte of the record. You could perform this drop on the '.dat' partition of a Micro Focus Indexed file, but you would then have to rebuild the '.idx' using Micro Focus 'fhrebuild' or D-ISAM 'dcheck'.
You can run the following demo, using dat1/custmast.dat & dat1/custmast.idx. The rcsz is 256, but you must specify 257 to uvhd using the '.dat' file.
cp /home/uvadm/dat1/custmast.dat dat1 - copy supplied files to your sub dir cp /home/uvadm/dat1/custmast.idx dat1
uvhd dat1/custmast.dat r257 - invoke uvhd on .dat file, with rcsz=257 ===========================
di 8(1),'D' - copy to tmp/custmast.dat.yymmddhhmmD
=========== - dropping records with 'D' in column 9
- dropping records with x'00' in column 257
(since option 'i' is specified)
uvhd displays a status line (such as shown above), reporting the number of records copied & the number dropped by the pattern test & by the ISAM delete flag test. The tmp file will be overwritten if another 'd' command is executed (records are not appended as they are for the 'write' command).
Copy starts at current position & ends at EOF (or max rec count). To copy the entire file, you must be positioned at the 1st record.
| r0 |
|
| di |
|
| d15i |
|
| d 77(2),'BC' |
|
Goto: Begin this document , End this document , UVSI Home-Page
| command 'z' |
|
| z100000 |
|
| Note |
|
#1. cp dat1/custmas1 tmp/cm1 - copy test file to tmp subdir
========================
#2. uvhd tmp/cm1 r256u - enter uvhd with update option 'u'
==================
tmp/cm1 bytes=8192 recs=32 mdate=2000071412 today=200007141244
r# 1 1 2 3 4 5 6
b# 0 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
64 IMO BC V9S1H1 604-754-5531 ..4V|...
4442222222222442535343222233323332333322222222222222222201357000
9DF00000000002306931810000604D754D55310000000000000000000246C000
128 .........W0....`........)X}..f3.....\.................4V}...f...
0000000005300016000000002570063100095000000000000000013570016000
0C0000C0270D0540C0000C0098D0263C0444C0000C0000C0000C0246D0056C00
192 ...............................f.....<........f.C
0000008900000000880000000018000680001300000000694222222222222222
00C0026C0000C0023C0000C0083C0056D0012C0000C0016D3000000000000000
tmp/cm1 rsz=256 totrecs=32 current=1 fsiz=8192 fptr=0 null=next,r#=rec,s=search,u=update,x=rollback,p=print,i=iprint,w=write,e=count ,g=genseq#,c=checkseq#,t=translate(ta=Asc,te=Ebc,tu=Upr,tl=Lwr,tc=Chars,tp=Pers) ,h1=char,h2=hex,q=quit,?=help -->
#3. --> z4096 <-- truncate file to 4096 bytes
===== ===========================
tmp/cm1 bytes=4096 recs=16 mdate=2000071412 today=200007141245
r# 1 1 2 3 4 5 6
b# 0 0123456789012345678901234567890123456789012345678901234567890123
0 130140 EVERGREEN MOTORS LTD. 1815 BOWEN ROAD NANA
3333332222454545444244545524542222233332445442544422222222224444
130140000056527255E0DF4F230C44E0000181502F75E02F140000000000E1E1
- - - - - - - etc, same as above - - - - - - -
Note the filesize is now displayed as 4096 (vs 8192) & recs count 16 (vs 32).
This command is very handy for dropping the MS-DOS EOF x'1A' from the end of large files, saving a file copy operation, before submitting to apps.
But Be Careful, you can destroy a lot of data if you make a mistake.
Goto: Begin this document , End this document , UVSI Home-Page
'uvhd' can be used to investigate any kind of file & is especially valuable for files with binary & packed data & that might not have LineFeeds.
'uvhd' works will for fixed record length data files. When you specify the correct record size, the data fields will be consistently displayed from record to record. For fixed length Indexed records (created by Micro Focus COBOL), you simply add 1 byte to the record size.
However, the default options (FIXED length) do not work well for VARIABLE length Indexed/Sequential records, because data records will not be consistent.
A test/demo file is provided & I suggest you try it first with the fixed length default option (rcsz=256 bytes), as shown below. We will then try it on the next page with the 'v' option & note the improvement.
uvhd dat1/testIDXf3 r256 <-- examine Variable length file (W/O option v) ========================
r# 1 1 2 3 4 5 6
b# 0 0123456789012345678901234567890123456789012345678901234567890123
0 0~......9911230948416799112309484167.>.......................P..
3700000033333333333333333333333333330300000000000000000009000500
0E00000099112309484167991123094841670E02000000001000000010000000
| note |
|
r# 3 1 2 3 4 5 6
b# 512 0123456789012345678901234567890123456789012345678901234567890123
0 ....................@P0010.0080 testIDXL- test file to create IS
0000000000000000000045333323333276774553227677266662762676676245
00000000000000000000000010E0080045349361D04534069C504F0325145093
64 AM Variable length file ..@P0020.0080 - in
4425676666626666762666622222222222222200453333233332222222222266
1D0612912C50C5E748069C500000000000000000000020E0080000000000D09E
128 put to 'cblIDX1.bat' which write variable file ..@P00
7772762266645532667227666627767627676666626666222222222222004533
05404F073F29361E21470789380729450612912C5069C5000000000000000000
The begining of each record is marked with '@', which indicates user data (vs deleted or system records). The 'P' is x'50', which is decimal 80, which is the record length, which of course may vary from record to record.
If desired you can recreate the variable length indexed test file as follows, if you have Micro Focus COBOL & have compiled the 'ux' utility versions (as shown in the install guide).
uxcp "fili1=dat1/testIDXL,typ=LST,rcs=254,filo1=dat1/testIDXf8,typ=IDXf3v60,isk1=0(4)" ================================================================================
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/testIDXf3 v <-- examine Variable length file (WITH option v) =====================
r# 1 1 2 3 4 5 6
b# 532 0123456789012345678901234567890123456789012345678901234567890123
0 @P0010.0080 testIDXF3 test file to create ISAM Variable length f
4533332333327677455322767726666276267667624544256766666266667626
000010E0080045349361D04534069C504F03251450931D0612912C50C5E74806
64 ile ..
66622222222222222200
9C500000000000000000
r# 10 1 2 3 4 5 6
b# 1292 0123456789012345678901234567890123456789012345678901234567890123
0 @T0100.0084 - here is an 84 byte record
4533332333322266762672662332677627666762222222222222222222222222
040100E00840D0852509301E084029450253F240000000000000000000000000
64
222222222222222222222222
000000000000000000000000
r# 12 1 2 3 4 5 6
b# 1468 0123456789012345678901234567890123456789012345678901234567890123
0 @x0120.0120 - here is a 120 byte record.........................
4733332333322266762672623332677627666762222222222222222222222222
080120E01200D08525093010120029450253F24EEEEEEEEEEEEEEEEEEEEEEEEE
64 ..................--------------------------------------->..
222222222222222222222222222222222222222222222222222222222300
EEEEEEEEEEEEEEEEEEDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDE00
With option 'v', the data record contents will be displayed consistently, as long as you read sequentially thru the file (enter for next record).
However you might not be able to use several of the uvhd commands such as jump to a specified record by keying the record# or '+' or '-' a number of records, because we don't know intervening record sizes & we get off track.
You can in fact get back on track by setting the current byte# to the nearest '@' symbol you see. The easiest way to get back on track is simply enter '0' to return to the begining of the file.
Note that searching for data works fine as long as you are on track.
s 2(4),'0090' <-- sample search to find last record shown above. =============
Goto: Begin this document , End this document , UVSI Home-Page
Uvhd with option v, reads only the data partition of Micro Focus variable length Indexed or Sequential record files. Command line option 'v' causes uvhd to look for & interpret the system control records & variable length record sizes, in order to display user data records in a consistent manner.
Browsing & searching sequentially will keep the record display on-track, but using the random access commands (jump to any specified record#), might cause the display to get off-track (display not starting at begin record). The following tips should help you to use option 'v' with success.
In November 2002, uvhd was enhanced to minimize the 'off the rails' problem. If variable record display option v4 (data records) & an invalid record header is encountered, uvhd will now scan for the next data record type x'40'.
r# 12 1 2 3 4 5 6
b# 1448 0123456789012345678901234567890123456789012345678901234567890123
0 @x0120.0120 - here is a 120 byte record.....
2222222222222222222247333323333222667626726233326776276667622222
00000000000000000000080120E01200D08525093010120029450253F24EEEEE
If you get this display after a record# jump, you can get back on track by entering 'b1468' = display starting from byte# 1468. You can see that the next record (identified by the '@' sign) is 20 bytes higher than the current setting, so just add 1448+20 = 1468.
uvhd dat1/testIDXF3 v5 <-- option 'v' defaults to 'v5'
======================
v1 - display file header (1st record)
v2 - display deleted data records
v4 - display active data records
v8 - display all records (including system records)
Goto: Begin this document , End this document , UVSI Home-Page
Option 'v' also works for IDXFORMAT8 (for files that may exceed 2 gigs).
A test/demo file is provided (dat1/testIDXf8). You can recreate as follows, if you have Micro Focus COBOL & have compiled the 'ux' utility versions (as shown in the install guide).
uxcp "fili1=dat1/testIDXL,typ=LST,rcs=40,filo1=dat1/testIDXf8,typ=IDXf8,isk1=0(6)" ================================================================================
uvhd dat1/testIDXf8 v =====================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 3.......0412300950506704123009505067.>...................(...(..
3F00000033333333333333333333333333330300000000000000000002000200
3E00000004123009505067041230095050670E02001800001060000008000800
64 ............................................X.7.X.7.............
00000000000000000000000000000000000000000000503A503A00000000000E
0000000900002210000000000000000000000000000A807480740000000000D0
128 ................................................................
0000000E000000000000000000000000000000000000000F0000000000000000
000000D04244010400000040000000C0000000000000003E0000000000000000
------ 192-960 not shown (all x'00's) ------
960 ................................................................
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
----- other system records bypassed to 1st data at 3120 -----
10 20 30 40 50 60
r# 2 0123456789012345678901234567890123456789012345678901234567890123
3120 @(BBQ010 BAR-B-Q 0019500 ......
424453332224452425222222222222223333333222000000
08221010000212D2D1000000000000000019500000000000
10 20 30 40 50 60
r# 3 0123456789012345678901234567890123456789012345678901234567890123
3168 @(CHR015 LAWN CHAIR 0004500 ......
424453332224454244445222222222223333333222000000
08382015000C17E038192000000000000004500000000000
10 20 30 40 50 60
r# 4 0123456789012345678901234567890123456789012345678901234567890123
3216 @(HAM010 CLAW HAMMER 0000950 ......
424443332224445244444522222222223333333222000000
0881D0100003C17081DD5200000000000000950000000000
Goto: Begin this document , End this document , UVSI Home-Page
The Vancouver Utilities (uxcopy,uxsort,uxqrpg,uxcp,uvhd) are compatible with Micro Focus COBOL variable length sequential & Indexed files (IDXFORMAT3 & 8).
We will document the most important fields in the file header for IDXf3/IDXf8. If desired, you can find all fields defined on the Micro Focus website.
Note that you can investigate the file headers using 'uvhd' with option 'v' See sample on the previous page.
000-003 - file header record length
- 1st 4 bits x'30' identifies a system record
- next 12 bits is header length if max record length is < 4095
- next 28 bits is header length if max record length is => 4095
008-014 - creation date/time yymmddhhmmsscc (indexed files only)
039-039 - organization (1=seqntl, 2=indexed, 3=relative)
043-043 - file type (3=IDXFORMAT3, 8=IDXFORMAT8)
048-048 - recording mode (0=fixed, 1=variable)
054-057 - maximum record length (big end format)
- example recsize 80 = x'00000050'
058-061 - minimum record length
128-135 - offset to End-of-File (8 bytes binary big end format)
140-141 - number of keys in Indexed file
000-000 - 1st 4 bits identifies the record type x'1_' - system record - duplicate occurrence record x'2_' - deleted record x'3_' - system record x'4_' - user data record x'5_' - reduced user data record x'6_' - pointer record x'7_' - user data record referenced by a pointer record x'8_' - reduced user data record referenced by a pointer record
000-001 - next 12 bits is the record length if max recsize < 4095 000-003 - next 28 bits is the record length if max recsize =? 4095
002-... - record data if max recsize < 4095 004-... - record data if max recsize => 4095
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
Option 'z' is provided to read BDW/RDW mainframe variable length files.
| z4 |
|
| z2 |
|
| z8 |
|
| z1 |
|
The following test/demo files are supplied in /home/uvadm/dat1:
| dat1/testBDW |
|
| dat1/testBDWe |
|
| dat1/testLST |
|
| dat1/testRDW |
|
| dat1/testRDWe |
|
We will 1st illustrate stripping the RDW prefixes from dat1/testRDWe. First examine the testRDWe file using option 'a1' (since we know the test file is EBCDIC & we want to be able to read the char line display). We also use option 's3' to space apart the 3 line groups of chars,zones,digits.
uvhd dat1/testRDWe a1s3 <-- examine the RDW test file =======================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ....DELL00 - Dell Inc. ....HP0000 - Hewlett Packard....IBM000 -
0100CCDDFF464C8994C984440100CDFFFF464C8A98AA4D8898980200CCDFFF46
080045330000045330953B000C008700000008563533071321940C0092400000
64 International Business Machines....MFC000 - Micro Focus COBOL
4C9A8998A899894CAA898AA4D888898A0200DCCFFF464D88994C98AA4CDCDD44
0953595139651302429552204138955200004630000004939606634203626300
128 ....MS0000 - Microsoft Corp.....REDHAT - Red Hat Linux ....SUN0
0100DEFFFF464D8899A98A4C99940100DCCCCE464D884C8A4D89AA440200EEDF
0C0042000000049396266303697B0C0095481300095408130395470004002450
192 00 - Sun Microsystems Ltd ....UVSI00 - UV Software Inc.
FF464EA94D8899AAAA89A4DA84440200EEECFF464EE4E98AA8984C984444
00000245049396282354203340000000452900000450266361950953B000
The entire file is only 252 bytes & contains 8 short variable length records:
Goto: Begin this document , End this document , UVSI Home-Page
This page will illustrate options 'z4' & 'z2' for 4 byte or 2 byte prefixes. Note that the binary record length INCLUDES the prefix size for option 'z4', BUT excludes the prefix size for option 'z2'.
We will show the 1st 3 records for 'testRDWe' (EBCDIC file with 4 byte prefixes) & for 'testRDWz2e (EBCDIC file with 2 byte record prefixes).
uvhd dat1/testRDWe z4a ======================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ....DELL10 - Dell Inc.
0100CCDDFF464C8994C98444
080045331000045330953B00
10 20 30 40 50 60
r# 2 0123456789012345678901234567890123456789012345678901234567890123
24 ....HP0010 - Hewlett Packard
0100CDFFFF464C8A98AA4D889898
0C00870010000856353307132194
10 20 30 40 50 60
r# 3 0123456789012345678901234567890123456789012345678901234567890123
52 ....IBM010 - International Business Machines
0200CCDFFF464C9A8998A899894CAA898AA4D888898A
0C009240100009535951396513024295522041389552
| Note |
|
uvhd dat1/testRDWez2 z2a ========================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ..DELL10 - Dell Inc.
01CCDDFF464C8994C98444
0445331000045330953B00
10 20 30 40 50 60
r# 2 0123456789012345678901234567890123456789012345678901234567890123
22 ..HP0010 - Hewlett Packard
01CDFFFF464C8A98AA4D889898
08870010000856353307132194
10 20 30 40 50 60
r# 3 0123456789012345678901234567890123456789012345678901234567890123
48 ..IBM010 - International Business Machines
02CCDFFF464C9A8998A899894CAA898AA4D888898A
089240100009535951396513024295522041389552
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
Now, we will demonstrate how you could extract text records & drop the binary record size prefixes. For this we will need some additional options. You can see all options earlier in this doc or using the ?help screens, but here are the options most relevant to RDW files & writing out text records.
| a1 |
|
| z# |
|
| z2 |
|
| z4 |
|
| z8 |
|
| z1 |
|
| a1 |
|
| c1 |
|
| n1 |
|
| n2 |
|
| r# |
|
| t1 |
|
| t2 |
|
| t3 |
|
| t4 |
|
| z# |
|
| z2 |
|
| z4 |
|
| z1 |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/testRDWe z4a1 =======================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ....DELL00 - Dell Inc.
0100CCDDFF464C8994C98444
080045330000045330953B00
uvhd displays the 1st record & waits for your command.
---> w999a1t2 <-- write all records (8) to tmp/testRDWe_yymmdd_hhmmssW
DELL00 - Dell Inc.
HP0000 - Hewlett Packard
IBM000 - International Business Machines
MFC000 - Micro Focus COBOL
MS0000 - Microsoft Corp.
REDHAT - Red Hat Linux
SUN000 - Sun Microsystems Ltd
UVSI00 - UV Software Inc.
| w999 |
|
| a1 |
|
| t2 |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd dat1/testRDWe z4a1 <-- rerun uvhd with option z4 for RDW ======================= and option a1 to translate char display to ASCII
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 ....DELL00 - Dell Inc.
0100CCDDFF464C8994C98444
080045330000045330953B00
---> wn2r50t3 <-- writes all records (8) to tmp/testRDWe_yymmdd_hhmmssW
- 'n2' append data-size as 4 numeric characters
- 'r50' to write all records fixed 50 bytes
- 't3' insert CR/LF at end record.
DELL00 - Dell Inc. 0024
HP0000 - Hewlett Packard 0028
IBM000 - International Business Machines 0044
MFC000 - Micro Focus COBOL 0032
MS0000 - Microsoft Corp. 0028
REDHAT - Red Hat Linux 0028
SUN000 - Sun Microsystems Ltd 0036
UVSI00 - UV Software Inc. 0032
uvhd tmp/testRDWe_yymmdd_hhmmssW t1h2 =====================================
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 DELL00 - Dell Inc. 0024..
4444332224666246622222222222222222222222222222333300
45CC000D045CC09E3E00000000000000000000000000000024DA
uvhd tmp/testRDWe_071109_125325W t1h2 <-- do NOT type all this
=====================================
uvhd tmp/*25W t1h2 <-- enter this if ls shows file suffix '25W' unique
==================
Goto: Begin this document , End this document , UVSI Home-Page
Here is the 1st 64 bytes of a test/demo file dat1/testBDWe. This is the Ebcdic with both BDW & RDW variable length prefixes. You can examine dat1/testBDWe with uvhd as follows:
uvhd dat1/testBDWe a1 <-- option 'a1' translates char line to ASCII =====================
10 20 30 40 50 60
0123456789012345678901234567890123456789012345678901234567890123
........DELL00 - Dell Inc. ....HP0000 - Hewlett Packard....IBM0
00000100CCDDFF464C8994C984440100CDFFFF464C8A98AA4D8898980200CCDF
1000080045330000045330953B000C008700000008563533071321940C009240
The 1st 64 bytes shows the 4 byte BDW, followed by RDW for 1st record (DELL), followed by 2nd record RDW+data (HP), followed by 3rd record RDW+data (IBM). uvhd displays data 'vertical hex', converting to horizontal hex we have:
| at byte 00 |
|
| at byte 04 |
|
| at byte 28 |
|
| at byte 56 |
|
Run uvhd twice, the 1st time to strip BDW hdrs,& a 2nd time to strip RDW hdrs:
uvhd dat1/testBDWe z4a1 <-- options z4=read BDW, a1=display ASCII =======================
---> w999 <-- write out, stripping BDW headers (from 2 blocks)
--> result is RDW only file (16 records)
uvhd tmp/testBDWe_yymmdd_hhmmssW z4a1 <-- z4=RDW, a1=ASCII display =====================================
---> w999a1t2 <-- write out, stripping RDW headers
- 'a1' translates data to ASCII
- 't2' inserts LineFeed Terminators
- result is text only file (16 records)
Goto: Begin this document , End this document , UVSI Home-Page
After using uvhd to write out records (text or otherwise) from your data files, you may sometimes wish to reformat that output for your desired purposes.
For example, prior to November 2007, there was only option 'a1' to translate the records displayed to ASCII, bit no option 'a2' to also translate the 'write' command output to ASCII ('a3' for both).
Without option 'a2' I would have used 'uvcp' as follows:
uvcp "fili1=tmp/testBDWe_yymmdd_hhmmssWe_yymmdd_hhmmssW,rcs=64,typ=LSTt\ ======================================================================= ,filo1=tmp/testBDWe.txt,tra=0(64)" ==================================
Instruction 'tra=0(64)' translates the records to ASCII. See uvcp.htm to see many other instructions you can use to reformat your data as desired (mvc, clr, rep, tre, tru, trl, sel, del, etc).
| Note |
|
Goto: Begin this document , End this document , UVSI Home-Page
uvhd tf/test100 <-- test100 to demo finding correct recsize =============== - recsize defaults to 256 when not spcfd on cmd line
WARNING: rcsz does not divide evenly into filesize
filename=/home/uvadm/tf/test100 options=
records=15 filesize=4000 recsize=256 fsize%rsize(remainder)=160
10 20 30 40 50 60
r# 1 0123456789012345678901234567890123456789012345678901234567890123
0 0001 tf/test100 one .0002 tf/test100 two
3333276276773332666222222222222222222220333327627677333277622222
0001046F45341000FE500000000000000000000A0002046F4534100047F00000
64 .0003 tf/test100 three .0004 tf/
2222222222222220333327627677333276766222222222222222222033332762
000000000000000A0003046F4534100048255000000000000000000A0004046F
128 test100 four .0005 tf/test100 five
7677333266772222222222222222222033332762767733326676222222222222
453410006F520000000000000000000A0005046F453410006965000000000000
192 .0006 tf/test100 six .0007 tf/test100
2222222033332762767733327672222222222222222222203333276276773332
0000000A0006046F4534100039800000000000000000000A0007046F45341000
filesize NOT multiple of recsize, 160 bytes remain rec#=1 rcount=15 rsize=256 fsize=4000 tf/test100 If Text file (with LineFeeds), quit/restart with option 't' If Variable (IDXFORMAT3,8,RDW), quit/restart w option v,x,or z If Fixed length records, change recsize now via command 'R' (R256 current) next evenly divisible record sizes lower/higher are --> R250/R400 OR you may continue (ignoring these warnings) -->
Goto: Begin this document , End this document , UVSI Home-Page
The NOT EQUAL '!' condition can be quite useful. You could use it to verify field contents. For example if all records should have 'BC' in cols 78-79, you could use the following search to verify:
| s 77(2),!'BC' |
|
Also note that when you use the <!> conditions, the field length must match the pattern length, if the pattern length is greater than 1. If the pattern length is 1 you can search any field length.
Goto: Begin this document , End this document , UVSI Home-Page
Goto: Begin this document , End this document , UVSI Home-Page