While I want to fetch data from mongocollection based on updated time in shell I'm facing this error. Where I'm passing the date in other sh file

Welcome to the MongoDB Community @Yugandhar_Prathi !

The --query parameter for mongoexport expects a query as a JSON document enclosed in quotes.

You can use shell command substitution to replace ./datequery.sh with the output of running that command, but the supported syntax is either single backticks (`command`) or $(command).

Currently you have used single quotes ('), which (in a shell context) will preserve the literal value of each character within quotes. The "39 47 … " sequence is ./datequery.sh converted to the decimal value of each character.

Either of these should work assuming ./datequery.sh is executable:

   --query="$(./datequery.sh)"
   --query="`./datequery.sh`"

I think the first form is more readable and consistent with the other variable substitutions using $.

Regards,
Stennie

1 Like