If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > concat the line back or replace \n to \r

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-17-08, 22:15
ymho ymho is offline
Registered User
 
Join Date: Jul 2006
Posts: 109
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:
A|1|
A
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)
Reply With Quote
  #2 (permalink)  
Old 06-20-08, 03:32
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On