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

前端 未结 6 2024
不知归路
不知归路 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-30 00:12

    Your input file has carriage returns at the end of the lines. You need to use dos2unix on the file to remove them. Or you can do this:

    sed 's/\(.*\)\r/"\1"/g'
    

    which will remove the carriage return and add the quotes.

提交回复
热议问题