replacing enter character in LINUX

Hi

1) I need to replace an "enter" character with another character.
I thought it should be like this (E.G)
replace all stirngs "LIAV"+enter with kokokoko:

:1,$s/LIAV^M/kokokoko/g

but it dose not work.

2) Also dose nayone know how to replace wildcards?
for example if the file looks like this
ABCDEF
AAAAA
ABBBCC
FFFFFF
FAFFFF

and I want to replace all stirngs that has "F<unknown char>F" so it will replace the last 2 lines.

Thanks :slight_smile:
Liav

Hi Following:

tr -d '\012'

This will delete the Enter( New Line ) Characters.

So something like:

cat file1 | tr -d '\012' > file2

cheers,
RK....

F....F problem

sed 's/^F.*F$/replacment text/'  oldfile > newfile

I think you have DOS (windows) files with the "^M" in them right? dos2ux or sometimes called dos2unix will fix that

both problems together

dos2ux myfile | sed sed 's/^F.*F$/replacment text/' > newfile

Thanks :slight_smile: