#Add a new line gg at the end of the /opt/b.txt file
str='gg'
sed -i '$a\'$str /opt/b.txt
--Note: There must be content in the file, and it cannot be empty, otherwise the command will be executed, although no error will be reported, but a new line cannot be added and the file content is empty.