It certainly is possible to replace
(any number of characters)(one or more specific characters)(End-of-Line marker)
with something else. The following will replace any line ending with the character
X with
foo:
With regards to your other questions:
1) I'm not sure I understand exactly what you want to do. Can you be a bit more specific?
2) The last line of a file can easily be retrieved with
tail:
Code:
tail -n 1 < filename