How to add double quotes to a line with SED or AWK?

前端 未结 6 1993
不知归路
不知归路 2020-12-29 23:32

I have the following list of words:

name,id,3

I need to have it double quoted like this:

\"name,id,3\"

I

6条回答
  •  一整个雨季
    2020-12-29 23:58

    Before using sed command, you can use \ as escape character then it will print " in your string. As an example, i put the similar string to first line of a text file with below command:

    var = "\"name,id,3\""
    sed -i '1i' "$var" /tmp/out.txt
    

提交回复
热议问题