AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
Expand all | Collapse all

Replace two strings at a time in a text file.

  • 1.  Replace two strings at a time in a text file.

    Posted Mon March 09, 2020 01:26 PM

    Originally posted by: pharryr


    I have a requirement to replace two strings at a time in a text file from within a BASH script.

     

    SomeCommand ${FindString} ${ReplaceWithString}

     

    Where…

    "SomeCommand" is usable in a BASH 5 script on AIX 7.2

    ${FindString} is an OS environment variable

    ${ReplaceWithString} is an OS environment variable

    The original file is updated, not just the command's buffer.



  • 2.  Re: Replace two strings at a time in a text file.

    Posted Tue March 17, 2020 06:38 AM

    Originally posted by: nagger


    Hi,

    This is a very basic shell script request.

    Use the mv command and sed.

     

    You should get some training, watch YouTube videos, get a friend that knows AIX or Linux or ask the question on Google.

    Good luck, Nigel