Hi,
I understood your question differently then Knut did and think something like this is what you're looking for.
Like Knut mentioned, here's an 'awk' example. The advantage is that first the complete file is read into memory and after that the memory content is written to the file on disk again (including the extra last line). With this you can overwrite the original file in one step because awk has finished reading the input filestream before the output filestream is created. (Offcourse this only works if there's enough memory available to store the complete file.)
Something that's going terribly wrong with 'sed', where you allways have to store the output in a helpfile first and overwrite the original with that.
Awk solution:
Code:
#!/bin/bash
awk ' { line[NR] = $0 }
END {
for(i = 1; i <= NR; i++)
print line[i] > FILENAME
print "" > FILENAME
}' $1
Sed solution:
Code:
#!/bin/bash
sed '$s/$/\
/' $1 > "${1}.tmp"
mv "${1}.tmp" $1
Regards