
Replacing the last occurrence of char on every line of file
Hi, i am looking for a windows-batch solution to the problem of, replacing the last occurrence of the given character on each lines of file. the input and the output should be as below:
algorithm:
replace the last "-" on each line with " AAA "
input file:
-some-text-here
some-morehere
blah-blah-
-end
output file:
-some-text AAA here
some AAA morehere
blah-blah AAA
AAA end
Actually i have a unix script to perform the task with sed, wit whom i replace every last / with :/" archives="
Code:
more file1 | sed 's/\(.*\)\//\1\" archives="/' > file2
Any help will be appreciated, thanks in advance..