I can't seem to use the Bash “-c” option with arguments after the “-c” option string

前端 未结 4 1798
感情败类
感情败类 2020-12-02 15:31

The man page for Bash says, regarding the -c option:

-c string If the -c option is present, then comma

4条回答
  •  伪装坚强ぢ
    2020-12-02 16:05

    You need to use single quotes to prevent interpolation happening in your calling shell.

    $ bash -c 'echo arg 0: $0, arg 1: $1' arg1 arg2
    arg 0: arg1, arg 1: arg2
    

    Or escape the variables in your double-quoted string. Which to use might depend on exactly what you want to put in your snippet of code.

提交回复
热议问题