Wild char getting expanded in echo

Hi All,
I am having a issue in a script. I am trying to execute a select * from a scirpt to a database and printing the the sql string. The * in the sqltring is printing all the files in the directory. How to handle it ?

..
..
sql="select * from emp"
execute ($sql)
echo $sql

Here my echo is not giving the sql command it is showing all the files in the directory.

sql='select * from emp'
execute "$sql"

The problem is with the echo . The execute $sql work fine. When it echo it expand it and print all file

Actually it's the same problem with echo as you had with execute .
Double-quote the argument to the command.

1 Like

this is the script . The printlog is called and the sqlcmd print select and all the files name in the log

_bkp_table_name=processed$_timestamp
  _sqlcmd="select * into $_bkp_table_name from processed"
print_log "\n$_sqlcmd"

print_log() {
       print $1
       print $1 >> $_status_file
}

I also tried this. assume I will get the output as *

$a="*"
$echo $a

this is listing all files

In addition to double-quoting $1 in print_log , I'd enable set -x in the script and in the function call and see what comes out....

1 Like

Adding quotes in printlog worked. Thanks a lot