0

My problem is exactly same as the one mentioned here

Remove New Line Character from CSV file's string column

But what i am looking for is a solution in shell script . I want the broken line to be replaced by newly modified attached line in my file . This is required for me as the RS in my csv file is newline character.

0

2 Answers 2

0

I do not know how your echo suppresses a newline (option -n or ending string with \c). A solution is considiring a line as incomplete when it does not end with a double quote. You can redirect the output to a new file.

while read line; do
        if [[ "$line" = *\" ]]; then
                echo "${line}"
        else
                echo -n "${line}"
        fi
done < input
Sign up to request clarification or add additional context in comments.

Comments

0

You can try this

sed  '/"[^"][^"]*$/ {
:again
N
s/\n//
/"[^"][^"]*$/ b again
}' input_file

/"[^"][^"]*$/ searches for unterminated quote

:again - a label

N - append next line

s/\n// - remove newlines

/"[^"][^"]*$/ b again - loop if there is still unterminated quote

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.