Hi Gio

I use something like the following to replace text in place, that is, in the original file - it uses the sed utility in QShell, which doesn't have an option in the utility itself to do this, so I direct the results to a temporary file and copy that back to replace the original:

export QIBM_CCSID=1208 && sed "1,5 s/fromtext/totext/" originalfile > /tmp/tempfile.tmp && mv /tmp/tempfile.tmp originalfile

I was working with XML files, so I set the CCSID in QShell to UTF-8 - you could leave that off, if you don't need it - the double ampersands mean to run the next utility if there are no errors in the one before - it is called an "and" list - each command has to be successful for the next one to run.

The "1,5" is the range of line numbers where you will search for "fromtext" - I believe if you leave it out, the entire file will be searched.

This version will replace the first instance it finds - if you want all instances replaced, put a "g" after the forward slash after "totext".

The right-arrow redirects output of sed to a temporary file.

mv command copies the temporary file back to the original.

I found this idea in a Google search a few years ago. There are other versions of sed that have an option to replace things in the file itself without the redirect and copy back. I didn't check the version in PASE, so that might be better - watch out for differences in how CCSIDs are handled between QShell and PASE.


On 1/15/2019 6:23 AM, gio.cot via RPG400-L wrote:
Hi all

I'm looking an example (possible in RPG) that replace some character with
other (that i want) inside an Ifs file

Thanks in advance


Questa e-mail è stata controllata per individuare virus con Avast antivirus.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].