I have the config file on local, whom I am appending some variables from different remote machines. The file content is as:
#!/bin/bash
name=bob
department=(Production)
name=alice
department=(R&D)
name=maggie
department=(Production R&D)
The latest values updated in the file are the last one. So the expected output in the config file should be:
#!/bin/bash
name=maggie
department=(Production R&D)
I want to remove the first two data of name and address except for the latest one which is last. But this should happen only if there are multiple same variables.
I referred and try this for my solution but not getting expected output: https://backreference.org/2011/11/17/remove-duplicates-but-keeping-only-the-last-occurrence/