How can I escape an arbitrary string for use as a command line argument in Bash?

后端 未结 8 1769
时光说笑
时光说笑 2020-12-08 13:44

I have a list of strings and I want to pass those strings as arguments in a single Bash command line call. For simple alphanumeric strings it suffices to just pass them verb

8条回答
  •  半阙折子戏
    2020-12-08 14:25

    Bash interprets exclamation marks only in interactive mode.

    You can prevent this by doing:

    set +o histexpand
    

    Inside double quotes you must escape dollar signs, double quotes, backslashes and I would say that's all.

提交回复
热议问题