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 ( ). Everything works fine except the line feed character. Any idea how I might be able to get the line feed ( ) to work? Below is what I've tried:
&1
QSH CMD('sed -e "s?&1? Line 1 Line 2 ?g" test.txt > test.out')
Line 1 n Line 2
QSH CMD('sed -e "s?&1? Line 1 \ Line 2 ?g" test.txt > test.out') QSH CMD('sed -e "s?&1? Line 1 \\n Line 2 ?g" test.txt > test.out')
I was unable to get sed to work. I ended up using awk utility to achieve it. Below is the awk command:
QSH CMD('export QIBM_CCSID=1252; awk ''{gsub(/&1/, "Line 1 Line 2", $0); print}'' test.txt > test.out')
2.1m questions
2.1m answers
60 comments
57.0k users