Link to home
Start Free TrialLog in
Avatar of xiaoyunwu
xiaoyunwuFlag for United States of America

asked on

linux shell substitute variable

I have list of tables in t.txt file, I need to substitute all the ${table} instance with the table name in t.txt file. the challenge here is after the single quote, the ${table} variable will not be substituted, like the following code, only the first ${table} will be substituted, the last two does not. How can I do this? Thanks.

for table in `cat t.txt`
do

curl -XPUT "http://localhost:9200/_river/${table}_river/_meta" -d '{
    "type" : "jdbc",
    "jdbc" : {
        "driver" : "oracle.jdbc.driver.OracleDriver",
        "url" : "jdbc:oracle:oci:@test",
        "user" : "test",
        "password" : "test",
        "sql" : "select * from ${table} where rownum<3"
    },
    "index" : {
        "index" : "database",
        "type" : "${table}"
    }
}' 

done

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xiaoyunwu

ASKER

Thank you, ozo!