I have a bash script which only contains bash variables. for example:
#!/bin/bash a="foo" b="bar"
I also have another script, which should change the values of the variables of the first script permanently, so after it is run, the first script should contain:
#!/bin/bash a="bar" b="bar"
I'm looking for the easiest way to achieve this. I know this can be done using
sed, but I also read that it should be possible to source the first script into the other script, and then just assign a new value to the variable. (I'd like to avoid regex or parsing if possible) I am, though, not sure if this only applies to the running shell, or if it actually updates the first script file as well. Is updating another script possible through sourcing or something else bash-specific, or should I just use
sed? (I know other tools can be used, such as
awk, but I'm not familiar with any of them)
For context, I'm trying to edit the
level-name value in my Minecraft server's
server.properties file, which isn't exactly a bash script by extension or shebang, but follows the exact same syntax. I could add a shebang to the file if that would be required for something more high-level than
sed to work. This is the script I want to change the
server.properties file from.