Search code examples
vicat

Shell script to create a yml file removes data after "$"


I am trying to create a yml file from a shell script which includes a sql query. This is the sample script

cat <<EOF>/test/queryTest.yml

This is a test
sql: "select * from schema.table$name"

After I run the shell script and check the yml file, anything after "$" is removed This is my yml

This is a test
sql: select * from schema.table

I would appreciate any thoughts on how to avoid this


Solution

  • Escape ("\") the $ sign.

    cat <<EOF>/test/queryTest.yml
    
    This is a test
    sql: "select * from schema.table\$name"