You could also use tr
:
tr -s '[:blank:]' '|'
It translates each character using to sets. According to the manual page:
-s
(or --squeeze-repeats
): replace each sequence of a repeated character that is listed in the last specified SET, with a single occurrence of that character (i.e. used to remove duplicates of the character to replace)
[:blank:]
: all horizontal whitespaces (use
instead if you're sure they are all tabs)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…