I'm trying to create a script which inserts a line at the end of a file. But if I call the script multiple times It shouldn't create the same entry multiple times in the file.
So If I'm inserting the file on the 21st line, which I know is the end of that file.
sed -i '21s/.*/IP=192.168.1.1/' ip
21st line is empty and because of that this command is not working. Is there anyway to insert a line to an empty string, by modifying this command?
I know of other methods to append to the end of file, but my major concern is not to create copies of the same line if the script is called multiple times.