print double quotes in shell programming

前端 未结 3 1237
春和景丽
春和景丽 2020-12-09 16:36

I want to print double quotes using echo statement in shell programming.

Example:

echo \"$1,$2,$3,$4\";

prints

3条回答
  •  半阙折子戏
    2020-12-09 17:11

    Use printf, no escaping is required:

    printf '"%s","%s","%s","%s";\n' $1 $2 $3 $4
    

    and the trailing ; gets printed too!

提交回复
热议问题