Bash - how to put each line within quotation

后端 未结 7 1287
既然无缘
既然无缘 2020-12-30 21:14

I want to put each line within quotation marks, such as:

abcdefg
hijklmn
opqrst

convert to:

\"abcdefg\"
\"hijklmn\"
\"opqrs         


        
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 21:46

    This sed should work for ignoring empty lines as well:

    sed -i.bak 's/^..*$/"&"/' inFile
    

    or

    sed 's/^.\{1,\}$/"&"/' inFile
    

提交回复
热议问题