When I run this command, it literally posts $line
into Elasticsearch instead of the lines of file.txt
cat file.txt | while IFS= read -r line; do curl -d '{ "field" : "$line" }' -H "Content-Type: application/json" -POST "http://localhost:9200/indexname/doc"; done;
file.txt consist of:
This is line one.
This is line two.
This is line three.
This is Elasticsearch 7.2 on Centos 7.
I tried escaping $line
as in \$line
and ($line)
or "$line"
but it POSTS the actual value of \$line
and ($line)
or "$line"
Expected data to be put into Elasticsearch:
{ "field" : "This is line one." }
{ "field" : "This is line two." }
{ "field" : "This is line three." }
actual data put into Elasticsearch
{ "field" : "$line" }