2 added 200 characters in body
source | link

Again I am attempting to alter configuration file via script.

I looked into jq but jq seems to support the .json format alone.

.vdf is almost exactly like .json except that there are no commas.

here is an attempt at what I want to do but with sed.

#!/bin/bash

text_to_find='                  "9420"
                    {
                        "LastPlayed"        ".*"
                    }'
text_to_put='                   "9420"
                    {
                        "LastPlayed"        "1554153269"
                        "ViewedLaunchEULA"      "1"
                        "ViewedSteamPlay"       "1"
                        "BadgeData"     "02000000080b"
                        "LaunchOptions"     "PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1 %command%"
                    }'
sed -i "s|$text_to_find|$text_to_put|1" myTestFile 

that returns: "sed: -e expression #1, char 13: unterminated `s' command"

and it probably would fail to match Last played because I don't think in this context ".*" would still be interpreted.

here's an example of the test file :

https://pastebin.com/qFcEhTEf

Again I am attempting to alter configuration file via script.

I looked into jq but jq seems to support the .json format alone.

.vdf is almost exactly like .json except that there are no commas.

here is an attempt at what I want to do but with sed.

#!/bin/bash

text_to_find='                  "9420"
                    {
                        "LastPlayed"        ".*"
                    }'
text_to_put='                   "9420"
                    {
                        "LastPlayed"        "1554153269"
                        "ViewedLaunchEULA"      "1"
                        "ViewedSteamPlay"       "1"
                        "BadgeData"     "02000000080b"
                        "LaunchOptions"     "PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1 %command%"
                    }'
sed -i "s|$text_to_find|$text_to_put|1" myTestFile 

here's an example of the test file :

https://pastebin.com/qFcEhTEf

Again I am attempting to alter configuration file via script.

I looked into jq but jq seems to support the .json format alone.

.vdf is almost exactly like .json except that there are no commas.

here is an attempt at what I want to do but with sed.

#!/bin/bash

text_to_find='                  "9420"
                    {
                        "LastPlayed"        ".*"
                    }'
text_to_put='                   "9420"
                    {
                        "LastPlayed"        "1554153269"
                        "ViewedLaunchEULA"      "1"
                        "ViewedSteamPlay"       "1"
                        "BadgeData"     "02000000080b"
                        "LaunchOptions"     "PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1 %command%"
                    }'
sed -i "s|$text_to_find|$text_to_put|1" myTestFile 

that returns: "sed: -e expression #1, char 13: unterminated `s' command"

and it probably would fail to match Last played because I don't think in this context ".*" would still be interpreted.

here's an example of the test file :

https://pastebin.com/qFcEhTEf

1
source | link

Replace part of a vdf file

Again I am attempting to alter configuration file via script.

I looked into jq but jq seems to support the .json format alone.

.vdf is almost exactly like .json except that there are no commas.

here is an attempt at what I want to do but with sed.

#!/bin/bash

text_to_find='                  "9420"
                    {
                        "LastPlayed"        ".*"
                    }'
text_to_put='                   "9420"
                    {
                        "LastPlayed"        "1554153269"
                        "ViewedLaunchEULA"      "1"
                        "ViewedSteamPlay"       "1"
                        "BadgeData"     "02000000080b"
                        "LaunchOptions"     "PROTON_NO_ESYNC=1, PROTON_DUMP_DEBUG_COMMANDS=1 %command%"
                    }'
sed -i "s|$text_to_find|$text_to_put|1" myTestFile 

here's an example of the test file :

https://pastebin.com/qFcEhTEf