I'd suggest doing this in LUA - you have more control but you could do it using shell script. My examples will be from LUA so take that into account
To get the contents of the config file you'd use a callback to the controller like:
local probecmd = pds.create()
pds.putString(probecmd, "name", "cdm")
response, retcode = nimbus.request(RobotPath .. "/controller", "probe_config_get", probecmd)
This will allow you to use the response table to determine if you need to do whatever it is that you are doing.
To make changes you do something like:
local options = pds.create()
pds.putString(options, "/disk/ignore_filesystem", "/.*snap.*/")
local args = pds.create()
pds.putString(args, "name", "cdm")
pds.putPDS(args, "as_pds", options)
local resp,rc = nimbus.request(RobotPath.. "/controller", "probe_config_set", args)
pds.delete(args)
Then restart to put into effect:
output2,return_status2 = nimbus.request ( RobotPath .. "/cdm", "_restart" )