Reputation: 8505
i have a delete statement delete * from table_name;
. Currently shell expands it to list all existing files in current directory. How can i escape it, so that the string that is passed to sqlplus is indeed "delete * from table_name". I tried \*
'*'
and \\*
and none of them work.
The exact script is
#!/bin/bash
table_name = $1
delete_sql= "delete * from $table_name;"
echo $delete_sql > abc.sql
Upvotes: 2
Views: 177
Reputation: 59118
You just need to quote the variable (and fix your spacing around the =
sign):
#!/bin/bash
table_name=$1
delete_sql="delete * from $table_name;"
echo "$delete_sql" > abc.sql
Upvotes: 3
Reputation: 436
How about
echo "delete * from table_name" | sqlplus
or
echo "delete * from table_name" > mystatements.txt
sqlplus @mystatements.txt
On a side note, you don't need to specify * in a delete statement - all fields in the matching rows are deleted.
Upvotes: 5