ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Update IFS file using REXX/CL ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update IFS file using REXX/CL ?

    Hi

    I am looking for an idea how to :

    read IFS file, and replace some strings in it.
    For example:

    ifs file looks as:

    aaa bbb ccc
    ddd bbb ggg
    I need to replace via a program (not using editor) - all bbb with TTT and all aaa with YYY

    Thanks for your idea/sample

  • #2
    Re: Update IFS file using REXX/CL ?

    You can use sed, but you'll have to run the output into another file. Then you can rename or delete the input file and rename the output file.

    In this code, t1.txt is the input and t2.txt is the output.

    Code:
    sed -e s/aaa/YYY/g -e s/bbb/TTT/g t1.txt > t2.txt
    mv t1.txt t1.txt.old 
    mv t2.txt t1.txt

    Comment


    • #3
      Re: Update IFS file using REXX/CL ?

      Thanks !!!

      First time I hear about sed...

      Can it be invoked from within REXX program ?

      is it part of scripting language that should run under QSH ?

      many thanks !!!

      Comment


      • #4
        Re: Update IFS file using REXX/CL ?

        Run it within Qshell.

        Comment


        • #5
          Re: Update IFS file using REXX/CL ?

          "Native" REXX in the AS/400 line has no direct access to streamfiles. You would use REXX to run CL commands that ran Qshell utilities (e.g., sed) if REXX was desired.

          More commonly, CL would be run directly, outside of REXX, to do the work. And at V5R4 and later, the work can be done with ILE CL without needing to reference Qshell utilities.

          Side note: For some interesting advanced work, non-native REXX (e.g., Object REXX) can be installed and run in PASE. With those, streamfiles are no problem; but they're not well equipped for accessing native objects.
          Tom

          There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

          Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

          Comment


          • #6
            Re: Update IFS file using REXX/CL ?

            Sed, the stream editor, is a Unix utility. You can find plenty of information about it on the Web. Just google it.

            REXX has never been big on i even though it's powerful. I use it for one-shot tasks, not production work, and I am far from competent with it.

            Comment

            Working...
            X