I have a search I'd like to run against a zOS dataset, and I know how to form the grep command. I have access to the machine via Unix system services, how to I address a dataset from that environment?
-
2+1 I think it is the first z/OS question around here :) – kubanczyk Feb 03 '12 at 21:26
-
1@kubanczyk I've got plenty more if you want them ... – C. Ross Feb 04 '12 at 01:04
-
Absolutely - I don't think we have many z/OS folks but good questions would go a long way to attracting them :) – voretaq7 Feb 04 '12 at 01:23
-
some doubts are cleared after reading this question. thanks – Premraj Nov 12 '17 at 07:48
6 Answers
No need to cp first. You can cat, tail, grep etc. The thing to remember is the special quoting and that the DSN is preceded by two slashes:
cat "//'s052WX.EO.REXX(MYREXXSOURCE)'" | grep parse
If you look in the UNIX command reference manual under the cp command there’s more info.
- 51
- 2
How big a data set are we talking about?
The Unix system services cp
command can take data sets as a source, and a Unix file (or directory) as a target, so conceivably if the data set is small enough you can copy it into files and grep
away to your heart's content.
As an alternative, if you can open your data set in ISPF
on the z/OS machine you may want to consider using FINDRX (which gives ISPF basic regex capability) -- I've never used it myself though so I can't vouch for it working or not.
- 79,345
- 17
- 128
- 213
-
The data sets aren't that big (COBOL source), but there are 200+ of them ... – C. Ross Feb 04 '12 at 01:05
Nowadays you can use dgrep
command
As the manual says:
"Search for a pattern across all datasets (partitioned and sequential) matching one or more dataset patterns"
The syntax:
dgrep [-hinvd] [-C<num>] <pattern> [<dataset-pattern>]+
-h: syntax
-i: ignore case
-n: display line numbers
-v: print names of datasets being searched
-d: print debug messages
-C: display <num> lines of context around a match
For example:
$ dgrep DSALET36 IBMUSER.*.ISPPROF
IBMUSER.SYSTEM.ISPF.ISPPROF ISRLLIST 34
More applications and examples: here
- 11
- 1
I came across this thread after banging my head against the wall for about an hour. My expereince - as very much a newbie on Z/OS, MVS, etc - is that grep against a PD (or is it a PDS, or a DSN, who knows!) is that this cannot be done directly
So, let's say I have text in a location like this: MYUSERID.SOME.DATA(DATA1) (let me just interject, I have no idea how to refer to such a data "thing", I think it's a "PD")
Now, if I try to grep against the PD, using what seems like reasonable syntax:
===>grep FindMe "//'MYUSERID.SOME.DATA(DATA1)'"
$ grep: FSUM6261 read error on file "//'MYUSERID.SOME.DATA(DATA1)'": EDC511
3I Bad file descriptor.
Some other UNIX utility functions do work, for example:
===>cat "//'MYUSERID.SOME.DATA(DATA1)'"
and
===>cp "//'MYUSERID.SOME.DATA(DATA1)'" ./data.data
Others, rather unhelpfully, do not:
==>ls "//'MYUSERID.SOME.DATA(DATA1)'"
ls: FSUM6785 File or directory "//'MYUSERID.SOME.DATA(DATA1)'" is not found
AND - don't forget, the pipe is your friend, except it may not be the "|" character. It might very be the "!" (exclamation point) character.
This is basically an exercise in "try it out" the way you would in a real OS/SHELL combination, linux/BASH for example, and when that doesn't work, come up with a workaround for this idiotic, archaic System.
So my solution to your exact question is:
===> cat "//'MYUSERID.SOME.DATA(DATA1)'" ! grep FindMe
- 1
As far as i know there are two options:
Copy files to uss-filesystem and
grep
there as mentioned above; works for me.Create an external link (
~ /usr/sbin/mount -f host.quali.pda -O 'SYNC(120)' mountpoint
) andgrep
via that link; currently not working for me because of rights-restrictions.
The cat
-suggestion works well for a single file, but not for all pds-members (at least i was not able to make it work).
- 43,252
- 2
- 75
- 122
- 101
- z/OS supports UNIX (Single UNIX Specification) APIs and applications through USS (UNIX System Services).
- The Open Group certifies z/OS as a compliant UNIX operating system – with UNIX/Linux-style hierarchical HFS and zFS file systems.
- 385
- 5
- 13