View previous topic :: View next topic
|
Author |
Message |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
I’m trying to apply some checks against a PDS member in OMVS using regex pattern matching, such as:
cat "//'<some pds member>'" | egrep -n '^abc'
problem is that the tokens ^ and $ seem to be ignored ..
any help appreciated |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 Location: Bamberg, Germany
|
|
|
|
The egrep utility is fully supported for compatibility with older UNIX
systems. However, use grep -E instead because it may provide greater
functionality and is considered the standard for portable UNIX applications
as defined by POSIX.2 IEEE standard 1003.2-1992. |
|
Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
same issue - it makes no difference.
I've also tried copying the file into my user directory and using:
cat <file> | grep -E '^abc' |
|
Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
i think it must be a code page issue- i'll investigate further |
|
Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
Root cause is that z/OS UNIX files use IBM-1047, MVS use IBM-037 as default.
this formulation works :
cat <file> | grep -E '¬abc' |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 Location: Bamberg, Germany
|
|
|
|
Your terminal emulation should be able to switch between different CPs. Otherwise I recommend accessing OMVS via a telnet client like PuTTY (or KiTTY). |
|
Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
what I still can't figure out is why the following in OMVS:
echo 'abcd\nefgh' | grep -E 'ab.*\nef'
returns empty |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 Location: Bamberg, Germany
|
|
|
|
You try to grep a Multiline. Better use awk or sed in such cases.
Code: |
echo 'abcd\nefgh' | sed -n '/ab.*/,/ef/p;' |
Output:
Code: |
+ echo abcd\nefgh
+ sed -n /ab.*/,/ef/p;
abcd
efgh |
|
|
Back to top |
|
 |
jzhardy
Active User
Joined: 31 Oct 2006 Posts: 141 Location: brisbane
|
|
|
|
excellent! thanks |
|
Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1371 Location: Bamberg, Germany
|
|
|
|
A bit care is needed as the expression means /Start expression/ and /End expression/. Everything in between should be printed IIRC. |
|
Back to top |
|
 |
|