Thanks in advance for any suggestions.
Ewout
Why grep? You can use CPYF to search for a pattern in a
record in any type of physical or logical file.
Example:
I have a customer master file where the first name begins
in position 10 within the record.
CPYF FROMFILE(CUSMST) TOFILE(*PRINT) INCCHAR(*RCD 10 *EQ 'Stephen')
will find and print all records containing "Stephen" in this field.
CPYF FROMFILE(CUSMST) TOFILE(*PRINT)
INCCHAR(*RCD 10 *EQ X'E2A38597888595') does the same...(hex value of
"Stephen").
CPYF FROMFILE(CUSMST) TOFILE(*PRINT) INCREL((*IF CUFNAM *EQ 'Stephen'))
will do the same, but it uses a field comparison.
In all three cases, you can specify a file name as the TOFILE parameter,
and it will create a file and copy into the file the found records.
Example:
CPYF FROMFILE(CUSMST) TOFILE(QTEMP/CUSMSTXXX)
MBROPT(*REPLACE) CRTFILE(*YES) INCCHAR(*RCD 10 *EQ X'E2A38597888595')
Steve Landess
Austin, Texas
(512) 423-0935
I want to use regular expressions for the search pattern. I am afraid that
CPYF doesn't recognize these expressions.
Regards,
Ewout
"Steve Landess" <steve_...@hotmail.com> schreef in bericht
news:%F9Nb.1604$n8....@be1.texas.rr.com...
[...]
Well that shoots down SQL AFAIK, unless you only need '%' - any string,
or '_' - any single char.
I would suggest that your best best would be using Java or Perl. Both
offer regular expressions and are available on the iSeries. Java may be
a better bet, since it is built into the OS whereas Perl has been ported
and I've heard rumours of difficulty with it on OS/400.
http://java.sun.com/developer/technicalArticles/releases/1.4regex/
http://java.sun.com/docs/books/tutorial/extra/regex/
Also, REXX apparently has a similar functionality with it's parse()
function but it's a different syntax.
HTH,
Charles
In article <bu3bmb$2it$1...@news4.tilbu1.nb.home.nl>, ewout...@planet.nl
says...
Note that grep's abilities to search non-character fields are
limited, and that code page problems may confound things a bit.
There's really nothing special about a source PF vs a regular PF
except that the record format is predefined with line number and
date fields ahead of the text field.
--
Dan Hicks
Don't anthropomorphize computers. They don't like it.
Therefore, you cannot use grep to search through a physical file that has
fields defined.
"Dan Hicks" <danh...@ieee.org> wrote in message
news:400B369B...@ieee.org...
And I was given to understand that you COULD access a DB file from
IFS, though I've never tried it personally. I'll try to remember to
try it tomorrow.
--
Dan Hicks
If the wind will not serve, take to the oars. --Latin proverb
My definition of database file was not intended to be exhaustive, merely
explanatory.
"Dan Hicks" <danh...@ieee.org> wrote in message
news:400C9A1C...@ieee.org...
For reference, traditional objects map to:
/QSYS.LIB/libname.LIB/objname.type
And file members map to:
/QSYS.LIB/libname.LIB/objname.FILE/mbrname.MBR
Where
"libname" is the library name (remember, every library has an object of
type *LIB in library QSYS)
"objname" is the object name
"type" is the object type, without the "*"
"mbrname" is the member name
Most database files have only one member, which is usually the same as the
file name. But database files can have multiple members. Source files are a
special type of database file.
Some examples...
LIBA/FILE1 *FILE is also known as /QSYS.LIB/LIBA.LIB/FILE1.FILE
Member LIBA/FILE2(FILE2) is also known as
/QSYS.LIB/LIBA.LIB/FILE2.FILE/FILE2.MBR
LIBA/I001 *PGM is also known as /QSYS.LIB/LIBA.LIB/I001.PGM
If you want to see these names, I suggest you use wildcards to limit the
number of names returned, unless you have a small library. If you wrklnk on
'/QSYS.LIB', you're in for a wait. This also applies to a share accessed
from a PC.
"Dan Hicks" <danh...@ieee.org> wrote in message
news:400C9A1C...@ieee.org...
Source files and those physical files that were created with CRTPF xxxx
RCDLEN(nnn) can be accessed by grep
"Dale Berta" <da...@epix.net> wrote in message
news:9QlPb.10357$Bv6.3107444@news1.epix.net...
"Tim M" <scot...@cox.spammerssuck.net> wrote in message
news:5WnPb.26579$ii6.13154@okepread05...
Ah, there's the point of misunderstanding -- files created with
CRTPF RCDLEN **are** database files. They just have one field,
defined as all characters.
If you can't grep a file with multiple fields, you might get away
with grepping a logical that redefines the view to be one large
character field.
--
Dan Hicks
Do not let what you cannot do interfere with what you can do.
--John Wooden
--
Dan Hicks
Let him that would move the world, first move himself. --Socrates
Logical files are always ineligible.
"Dan Hicks" <danh...@ieee.org> wrote in message
news:400F368...@ieee.org...