IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

using EGREP in OMVS


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Wed Oct 12, 2022 9:20 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1295
Location: Bamberg, Germany

PostPosted: Wed Oct 12, 2022 9:30 am
Reply with quote

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
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Thu Oct 13, 2022 3:02 am
Reply with quote

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
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Thu Oct 13, 2022 3:29 am
Reply with quote

i think it must be a code page issue- i'll investigate further
Back to top
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Thu Oct 13, 2022 5:42 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1295
Location: Bamberg, Germany

PostPosted: Thu Oct 13, 2022 9:46 am
Reply with quote

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
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Fri Oct 14, 2022 9:24 am
Reply with quote

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
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1295
Location: Bamberg, Germany

PostPosted: Fri Oct 14, 2022 10:19 am
Reply with quote

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
View user's profile Send private message
jzhardy

Active User


Joined: 31 Oct 2006
Posts: 131
Location: brisbane

PostPosted: Fri Oct 14, 2022 10:25 am
Reply with quote

excellent! thanks
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1295
Location: Bamberg, Germany

PostPosted: Fri Oct 14, 2022 10:46 am
Reply with quote

A bit care is needed as the expression means /Start expression/ and /End expression/. Everything in between should be printed IIRC.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts OMVS Shell Script not working properly. All Other Mainframe Topics 1
No new posts Backup directory in USS (OMVS) IBM Tools 3
No new posts Error executing command TSO OMVS - Cr... TSO/ISPF 5
No new posts Execution of REXX-DB2 in OMVS All Other Mainframe Topics 0
No new posts newlines removed when file is copied ... TSO/ISPF 1
Search our Forums:

Back to Top