Escape asterisk * in file when cat -ing it in ksh


If you were to want to read the contents of a file in ksh, and the file just so happens to contain problematic characters like *, do this in your script:

set -f

prior to doing:

sql=`cat $sql_file`;

 

More info (fromĀ http://www.computing.net/answers/unix/escaping-in-korn-shell/7016.html):

echo $-
ism
set -f
echo $-
isfm
echo $sample
test*

set +f
echo $-
ism
echo $sample
test1 test2 test3 test4

Leave a Comment