@AvinashRaj The thing is, his answer is understandable. This is the great part of SE that you edit the answer yourself to make it better.
all you need to do is replace the last star in this command sed -i '5s/.*/Good morning/' ~/Desktop/* with the last code he wrote file{1..4}.txt