I'm trying to use the sed command to replace a string in an IFS text file with another string that contains a line feed character (\n). Everything works fine except the line feed character. Any idea how I might be able to get the line feed (\n) to work? Below is what I've tried:
- The IFS text file name is test.txt. Below is the content of this file:
&1
- I ran the following command in an RPGLE program to replace the &1 with the text of "Line 1 \n Line 2", expecting that the \n will get translated into the carriage return and line-feed characters
QSH CMD('sed -e "s?&1? Line 1 \n Line 2 ?g" test.txt > test.out')
- The string replacement works, except the line feed (\n) charater. The result file, test.out, looks like below. The \n is being translated to character n:
Line 1 n Line 2
- I've also tried below and none of them works:
QSH CMD('sed -e "s?&1? Line 1 \\\n Line 2 ?g" test.txt > test.out')
QSH CMD('sed -e "s?&1? Line 1 \\\\n Line 2 ?g" test.txt > test.out')