find . and replace with . & newLine & ; in OSX

So I want to put some text into a txt (utf8 would be fine) and replace all instances of a period with (1) a period, (2) a new line and a (3) semicolon. I’ve been trying to figure out how to use sed for this via applescript or the terminal. (Something like this: sed ‘s/./.newLine;/g’ ). Any help would be appreciated!

How do I select a file to do find and replace on from terminal?
How do I tell the terminal to use sed “on” it?
How do I represent a new line in sed? (Like this \n?)
Is this ‘s/./.newLine;/g’ going to do what I want it to do? (If I get the right symbol for new line up.)

Hi, I will try to answer each of your questions as best I can…

I have created a text file on my desktop containing this line - “line one.line two.line three.line four”
Replacing all instances of ‘.’ with ‘. [newline];’ would result in:-
line one.
;line two.
;line three.
;line four

The problem with trying to use sed to replace the ‘.’, is that ‘.’ is a special character used by sed to match any single character!

The shell command (Terminal) I used to get this was:-

sed ‘s_[.]_.!;_g’ <Path/to/Desktop/Untitled.txt | tr ‘!’ ‘\n’

I have used the _ as a delimiter here, rather than / (personal preference) and have had to enclose the ‘.’ in the square brackets [.] telling sed to match exactly this character and replace every instance to ‘.!;’. I have then used the shell command ‘tr’ (translate characters) to convert the ‘!’ to a new line ‘\n’ (If your text is likely to contain the ‘!’ character, you will have to find another unique character)

This in an Applescript would look like this:-

set txtF to POSIX path of (choose file with prompt "Choose a file")
do shell script "sed 's_[.]_.!;_g' <" & txtF & " | tr '!' '\\n' > ~/Desktop/converted.txt"

Note that the last ‘\n’ of the tr has had the ‘' escaped (’\')

To select a file to perform this command on, in the terminal, you simply have to provide the path to that file:-
So, as in the Applescript above you can give the first sed command
sed ‘s_[.]_.!;_g’

provide the path to the file you want to run this command on

then add the tr after a ‘pipe’ ‘|’
| tr ‘!’ ‘\n’

resulting in
sed ‘s_[.]_.!;_g’ </Users/your_username/Desktop/Untitled.txt | tr ‘!’ ‘\n’

I could not work out how to tell sed to generate a new line, hence why I used tr!

I hope this helps!

It does! Thank you:D