我想编辑特定文件的文本

我想编辑特定文件的文本

我想修改一下配置文件,如下图。作为 shell 脚本我能做什么?

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Touch"
        Option  "Calibration"   "166 3939 186 3814"
        Option  "SwapAxes"      "1"
        Option  "InvertX"   "on"
        Option  "InvertY"   "on"
EndSection

Section "InputClass"
        Identifier      "calibration"
        MatchProduct    "Touch"
        Option  "Calibration"   "166 3939 186 3814"
        Option  "SwapAxes"      "1"
        Option  "InvertX"   "off"
        Option  "InvertY"   "on"
EndSection

答案1

甚至

sed -i '/InvertX/s/"on"/"off"/' file_name

答案2

尝试这个:

sed -i 's:"InvertX"   "on":"InvertX"   "off":g' file_name

相关内容