0

I would like to modify the configuration file, as shown below. What can I do as a shell script ?

before

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

after

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

Or even

sed -i '/InvertX/s/"on"/"off"/' file_name
  • won't that act on Option rather than "on"? modified command: sed -i '/InvertX/s/"on"/"off"/' file_name – Sundeep Jun 2 '16 at 7:57
  • @spasic Sorry, but I don't understand your question. – Michael Vehrs Jun 2 '16 at 8:01
  • @spasic Yes, it would turn Option into Optioff. – riha Jun 2 '16 at 8:14
  • Ah, now I get it. – Michael Vehrs Jun 2 '16 at 8:16
  • 2
    alternatively, sed -i '/InvertX/ s/on/off/2' filename to change only the second occurence of on to off. – cas Jun 2 '16 at 9:32
2

Try this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.