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

前端 未结 4 1811
感情败类
感情败类 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:09

    Because '$0' and '$1' in your string is replaced with a variable #0 and #1 respectively.

    Try :

    bash -c "echo arg 0: \$0, arg 1: \$1" arg0 arg1

    In this code $ of both are escape so base see it as a string $ and not get replaced.

    The result of this command is:

    arg 0: arg0, arg 1: arg1

    Hope this helps.

提交回复
热议问题