I have a text file which has inputs for select statement.sqlplus -s $USERNAME/$PASSWORD@$HOST<<EOFspool $DIRECTORY/UPDATE.xlsselect acc,cr,dr from countwhere acc in ***$DIRECTORY/acc.txt***;spool off;exitEOFPlease let me know how to use the text file as input at highlighted part.
File input for select statement in shell scipt
shell script;text processing;sql
First, read the file into an array.This is for a file containing the values in one single line:read -ar values < $DIRECTORY/acc.txtFor a multiline file use a loop (one value per line):while read -r v; do    values+=($v)done < <(cat $DIRECTORY/acc.txt)According to Archemar's comment, the SQL syntax is var in ( value1, value2, ... ), so some text processing is needed.First, quoting:for i in ${values[@]}; do quoted_values+=(\$i\); doneSecond, delimiting with commas and spaces:limit=${#quoted_values[@]}for ((i=0; i<$limit; i++ )); do    values_string=$values_string${quoted_values[$i]}    ((limit-i-1)) && values_string=$values_string,    values_string=$values_string doneThe brackets around the value list will appear in the here document.sqlplus -s $USERNAME/$PASSWORD@$HOST<<EOFspool $DIRECTORY/UPDATE.xlsselect acc,cr,dr from countwhere acc in ( $values_string );spool off;exitEOFNot tested, so there may be a typo, etc. Comment if you have problems.