Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well your problem came because if you write <code>\n</code>, it's not necessarily treated as a new line, somebody have to translate the sequence of <code>\</code> followed by <code>n</code> as a newline. also same in <code>IFS="\n"</code> IFS needs to be set to something which evaluates to a newline, not a combination of <code>\</code> and <code>n</code>. Also orlist is a variable, you have not used it as an array, and at the for loop, it is not going to be treated as an array. I did some changes and it seemed to work fine</p> <pre><code>#!/usr/local/bin/ksh orlist="" orlist="T_TAB1 \n" orlist=$orlist"T_TAB2 \n" orlist=$orlist"T_TAB3 \n" orlist=$orlist"T_TAB4 \n" echo $orlist arrIdx=0 OLD_IFS=$IFS; IFS=$'\n' #IFS="" arraryIndix=0 for IndxList in `echo -e $orlist` do echo "Hello $IndxList " MYDIR[${arraryIndix}]=$IndxList ((arraryIndix++)) done IFS=$OLD_IFS echo "Finally ${MYDIR[@]}" </code></pre> <p>Output</p> <pre><code>T_TAB1 \nT_TAB2 \nT_TAB3 \nT_TAB4 \n Hello T_TAB1 Hello T_TAB2 Hello T_TAB3 Hello T_TAB4 Finally T_TAB1 T_TAB2 T_TAB3 T_TAB4 $ ksh --version version sh (AT&amp;T Research) 93t+ 2010-02-02 </code></pre> <p>Update following comments</p> <pre><code>FILEOR_SQL="" func() { echo "SET HEADING OFF" &gt;&gt; ${FILEOR_SQL} echo "SET TERMOUT OFF" &gt;&gt; ${FILEOR_SQL} echo "SET PAGESIZE 0" &gt;&gt; ${FILEOR_SQL} echo "SET LINESIZE 1000" &gt;&gt; ${FILEOR_SQL} echo "SET FEEDBACK OFF" &gt;&gt; ${FILEOR_SQL} echo "SET TRIMSPOOL ON" &gt;&gt; ${FILEOR_SQL} echo "SPOOL random " &gt;&gt; ${FILEOR_SQL} echo "SELECT * " &gt;&gt; ${FILEOR_SQL} echo "FROM $1" &gt;&gt; ${FILEOR_SQL} echo "WHERE REP_ARG = 2; " &gt;&gt; ${FILEOR_SQL} echo "SPOOL OFF" &gt;&gt; ${FILEOR_SQL} echo "COMMIT;" &gt;&gt; ${FILEOR_SQL} echo "SET HEADING ON" &gt;&gt; ${FILEOR_SQL} echo "SET TERMOUT ON" &gt;&gt; ${FILEOR_SQL} echo "SET PAGESIZE 14" &gt;&gt; ${FILEOR_SQL} echo "SET FEEDBACK ON" &gt;&gt; ${FILEOR_SQL} echo "SET TRIMSPOOL OFF" &gt;&gt; ${FILEOR_SQL} echo "EXIT;" } orlist="" orlist="T_TAB1 \n" orlist=$orlist"T_TAB2 \n" orlist=$orlist"T_TAB3 \n" orlist=$orlist"T_TAB4 \n" echo $orlist OLD_IFS=$IFS; IFS=$'\n' arraryIndix=0; for IndxList in `echo -e $orlist` do FILEOR_SQL="testfilesql"$arraryIndix func $IndxList ((arraryIndix++)) done IFS=$OLD_IFS </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload