On Fri, Feb 19, 2016 at 2:32 PM, Jousma, David <[email protected]> wrote:

> All,
>
> Been scratching my head all afternoon on this.   I have a text file in
> mainframe unix filesystem that is ascii format.   Bottom line is that in
> batch, I need to do a find/replace for certain data in it.
>
> Interactively, I know I can do it via ISPF with the EA(edit ASCII)
> command.   But I need to do it in batch, so unless someone has a clever way
> to do it, I'm thinking I need to copy it out to flat file, convert to
> EBCDIC, make the changes, and then copy it back to the unix filesystem from
> whence it came, converting it back to ascii and doing it in batch.
>
> Tried ICETOOL with OUTREC...BUILD...TRAN=ATOE, tried FTP, but don't seem
> to have the correct incantation to make that work, and I've tried OGETX,
> but no good results.
>
> Does anyone have some hints/tips to accomplish?
>
> Thanks, Dave
>


​Run a UNIX step using BPXBATCH. Use the //STDPARM DD to pass in a really
long parameter line to do something like:

//CHANGE EXEC PGM=BPXBATCH,REGION=0M
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDIN DD *
//STDPARM DD *
SH ​

​cd /directory/containing &&
cat ascii.file.txt |
iconv -f ISO8859-1 -t IBM-1047 |
sed -E 's/BUBBA/TROUBLE/g' ​ |
iconv -f IBM-1047 -t ISO8859-1 >new.file &&
mv new.file ascii.file.txt
/*
//


This changes all occurrences of BUBBA to TROUBLE. This would be equivalent
to the ISPF edit command: CHANGE 'BUBBA' 'TROUBLE' ALL . Note for this
simple case, the -E (extended regexp) is not needed. If you could use some
help with regular expressions, this is a good site:
http://www.regular-expressions.info/tutorial.html . Or just post the ISPF
CHANGE command that you'd like emulated using "sed". You could have
multiple 'sed' commands to do multiple edits. Or you could do a single sed
with multiple changes.

Note in the above, the multiple lines are all "mushed together" as if it
were a single long line. That is, the end-of-line doesn't indicate
_anything_ special. In fact, it is eliminated. That's why I have the && and
| between commands. The && ensures that the command sequence stops on an
error. And, of course, the pipe character, |, passes the data stream along.


-- 
The man has the intellect of a lobotomized turtle.

Maranatha! <><
John McKown

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to