How to escape single quote using awk in a bash script

后端 未结 4 813
不思量自难忘°
不思量自难忘° 2021-01-24 02:16

This is what I have so far, tried multiple ways but can\'t get it just right. My goal is to sanitize the input to prevent problems while inputting to mysql from text file

<
4条回答
  •  花落未央
    2021-01-24 02:59

    Since you requested "how to escape single quote using awk" here's a solution using awk:

    awk '{ gsub("\x27", ".");print $0}'
    

    where \x27 is the escape sequence representation of the hexadecimal value 27 (a single quote).

    For a list of all escape sequences see https://www.gnu.org/software/gawk/manual/html_node/Escape-Sequences.html

提交回复
热议问题