My variable contains the following string
I wish to replace \n with "space" so the expected output is:
I understand that the /n is not a new linein this case.
I'm on AIX using ksh shell. Below is all that I tried.
echo $str | sed -e "s#\n# #g";
echo $str | sed -e "s#\n#' '#g";
echo $str | sed -e "s#/\n#' '#g";
echo $str | sed -e "s#/\n# #g";
echo "${str///\n/ }"
echo "${str//\n/ }"
tr '\n' ' ' | echo $str
Unfortunately none of the above attempts helped.
anbu23
2
$ echo $str | sed -e 's#\\n# #g';
/fin/app/scripts /fin/app/01/sql
more Parameter2.out
/fin/app/01/scripts\\n/fin/app/01/sql
I tried your suggestion on a new string containing "\\n" which is read from a file.
Unfortunately, I m not able to replace the \\n
Below is what I tried.
echo $str | sed -e 's#\\\\n# #g';
Let me know if I should open a new thread of this ?
anbu23
4
$ echo '/fin/app/scripts\\n/fin/app/01/sql' | sed -e 's#\\\\n# #g';
/fin/app/scripts /fin/app/01/sql
$ echo '/fin/app/scripts\\n/fin/app/01/sql' > file
$ sed -e 's#\\\\n# #g' file
/fin/app/scripts /fin/app/01/sql
1 Like
ctsgnb
6
tr '\n' ' ' <( echo $str )
or
echo $str | tr '\n' ' '