Sample Header Ad - 728x90

How to replace pattern in last line

0 votes
4 answers
125 views
I'm trying to replace "}," by "}" from the last line of a file : My /etc/firefox/policies/policies.json file like this because I added the certificate lines using a for loop :
$ cat /etc/firefox/policies/policies.json
{
  "policies": {
    "Certificates": {
      "Install": [
        {"cert1.der", "/home/username/cert1.pem"},
        {"cert2.der", "/home/username/cert2.pem"},
$
Please note there no "\n" at the end of this file (yet). Before adding this to the end of my JSON file :
]
    }
  }
}
, how can I remove the last , : replacing "}," by "}" for example ? sed seems a complicated solution to do that according to [this solution](https://stackoverflow.com/a/17115550) . Is there a more readable solution using awk or perl ?
Asked by SebMa (2433 rep)
Sep 5, 2024, 05:47 PM
Last activity: Sep 6, 2024, 03:45 PM