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/
department=(Production R&D)is a syntax error. You need some quotes.is getting appended from the remote hosts where I cannot access the file to overwriteIf you can append (you have write access to the file), you can overwrite (in 99.99% of the cases).Appending is done by redirecting the sshpass output the fileGreat! So instead of>>use>.