Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006

    Unanswered: concat the line back or replace \n to \r

    if there is a extra \n inside a line which cause a extra new line found in text editor processing(e.g awk ...)

    e.g in a text file
    A|1|\n A
    B|1|\r B
    C|1|\v C
    in VI editor, it becomes:
    B|1|\r B
    C|1|\v C

    pls advise how to concat the line back or replace \n to \r (bcos \r & \n have similar effect in VB but different effect in unix)

  2. #2
    Join Date
    Jan 2007
    Jena, Germany
    What I don't understand is how you define a "line". Typically, a line is terminated by '\n', so how can you have a single line "A|1|\n A" in your text file? Especially because this line will actually be "A|1|\n A\n".

    To remove some of the newline characters, you could use a script (Perl or shell or whatever) that reads the file line by line, remembers the last line, then concatenates the next line to what you remember (under whichever conditions are applicable, i.e. when you consider two lines to be just one), then writes the concatenated line to a new file.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts