I have to run this script in 90 files which their filename starts with CD*. I want to call all these files and execute this command once.
Or schedule it to be executed at 1600hrs every day.
I want to output to the same i.e I'm modifying these file so input file has to have the same file as the output.
He actually doesn't want to change the last line. 'q' is a command that makes sed quit. '$' addresses the last line. So when the last line is encountered, sed exits so that second command never runs. See this thread.