I have a txt file under CentOS in which I want to replace any "tn"
with "tt"
. I tried this:
sed -i -E 's/tn/tt/g' myfile.txt
but it doesn’t work. I don’t know if CentOS doesn’t support regex in sed.
Any help is appreciated!
p.s.
Input(two lines):
1t2t3t$
4t5t6t$
Output(one line):
1t2t3tt4t5t6tt
In Editplus, the find regex is ‘tn’ and the replace is ‘tt’. Then all lines ending with ‘tn’ will become one line, and each ‘n’ is replaced by one additional ‘t’.
p.s.
my file is read like this (cat -A myfile.txt)
2
Answers
You may use this
perl
command to join lines if previous line has a single tab:(?!z)
is a negative lookahead to fail this match for last line of the file.You need to escape the backslashes.