I am using ksh.I have a file temp.txt with some pipe delimited data. one|two|three|four|fiveabc|def|pqr|lmn|xyzAs clear from example, the record ends with a new line character after the data value in the last column.However, I want the record to end with a pipe delimiter and a new line character as below:one|two|three|four|five|abc|def|pqr|lmn|xyz|I tried the following commands but still unsuccessful:tr '\n' '|\n' < temp.txtand sed -i 's/\n/|\n/g' temp.txtAm I missing something?
Replacing new line character with a pipe and a new line character
text processing
Unless you have joined lines, the \n doesn't appear in sed's pattern space: the end-of-line anchor is $.So with GNU sed:sed -i 's/$/|/' temp.txt