I have a requirement where I need to replace line feed characters appearing as part of a data field in a CSV files. Fortunately all the unnecessary linefeeds are followed by an '_' character. So I decided to used sed to preprocess the file. The following command in sed works if run it interactively.
sed -i -e ':a;N;$!ba;s/\n_/_/g' file
But in server, the command will get executed with sh -c "<command>"
To test it in local, I ran the same command with sh and it is not working. The command looks as follows.
sh -c "sed -i -e ':a;N;$!ba;s/\n_/_/g' file"
Not sure what I'm missing. Please help.