Search code examples
variablesunixifs

UNIX (AIX) Version of IFS <<< command


I've got a script working on Linux perfectly, but when trying to get this running on a UNIX box, there is one command I cannot seem to convert for the life of me, its...

 IFS=\| read TableName DataBase Schema MD5Check<<< "$NextFile"

$NextFile is a variable created in a line of code before which will contain 4 columns, separated by a |

Its the <<< which isn't liked, but I just cannot find the alternative to reading from a variable in UNIX. Any help?


Solution

  • The portable way to do this is:

    IFS=\| read TableName DataBase Schema MD5Check<<EOF
    $NextFile
    EOF
    

    But if you can restrict the scope of the variables (you can, but you may need to refactor):

    echo "$NextFile" | { IFS=\| read TableName DataBase Schema MD5Check
    # Inside the braces, the variables are defined
    }