user1241438
user1241438

Reputation: 1543

unix read command with special charecters

I am writing a shell script which will read a user input and do some processing

echo "Enter your query \n"
read query
echo $query > temp

I am facing an issue when i enter any special characters. For example if i enter

select * from temp;

the * in the select statement is getting converted into all the file names in the directory.

Upvotes: 1

Views: 198

Answers (1)

chrisaycock
chrisaycock

Reputation: 37930

Use double quotation marks to prevent looking in the file system:

echo "$query" > temp

Upvotes: 2

Related Questions