Artificial intelligent assistant

Replace a string in a string with a new line (\n) in Bash I tried this command: [silas@mars 11]$ string=xyababcdabababefab [silas@mars 11]$ echo ${string/abab/"\n"} xy\ncdabababefab [silas@mars 11]$ I also tried to replace "\n" to '\n' and to \n . I can't use AWK or sed (this is a part from a homework exercise, and the teacher don't allow to use in this specific exercise).

You should use **`-e`** with `echo` as follows:


echo -e ${string/abab/'\
'}


From manpage:


-e enable interpretation of backslash escapes



If -e is in effect, the following sequences are recognized:

\\ backslash

\a alert (BEL)

\b backspace

\c produce no further output

\e escape

\f form feed

\
new line

\r carriage return

\t horizontal tab

\v vertical tab

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8c897d071c9e8364726aa658b2e6d61c