This question already has an answer here:

I'm trying to call a command from a variable in a script with a specific locale, example :

$ myYTDL="LANG=C.UTF-8 youtube-dl --get-filename"

but each time I try and call it in the script, I get :

$ $myYTDL $url
LANG=C.UTF-8: command not found

How can I do that ?

marked as duplicate by Kusalananda bash Mar 11 at 22:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • @kusalananda I thought my question was one specific to the assignment before the command in the variable. I didn't know this could be solved by calling the eval builtin : myYTDL="eval LANG=C.UTF-8 youtube-dl" Thanks bro :) – SebMa Mar 12 at 10:36
  • 1
    That's definitely the wrong take-home message from that question. Use a shell function or put the command into an array. – Kusalananda Mar 12 at 11:07