![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's | manas6 | UNIX for Dummies Questions & Answers | 0 | 06-05-2008 03:44 AM |
| awk, join or sed | jkl_jkl | Shell Programming and Scripting | 1 | 04-15-2008 02:55 AM |
| Join | jazz8146 | UNIX for Dummies Questions & Answers | 5 | 01-29-2008 08:42 AM |
| join (pls help on join command) | summer_cherry | Shell Programming and Scripting | 1 | 12-31-2007 02:19 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Cut Return and Join
I have a file that has sporadic lines being split by a carriage return. I need to remove the carriage return and join the current line with the next (ctr +j). The line being split is not a consistent character length.
Below is a sample of my data: ===================================== REQC#WH01#RQ2002-99075# #A#""# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ REQC#WH01#RQ2002-99076# #A#"1024693613^Doherrera^Doscar$ herr"# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # $ ==================================== The second and third line should be on 1 line. The # character is being used as a delimiter I appreciate any help thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I don't understand the problem well enough to offer a solution. We need a lot more explanation here.
If lines 1 - 3 should be one line and lines 4-6 should be the second and so on, this would be easy. But you say the splits are sporadic. How can we determine exactly which lines are to joined? I'm sure you understand exactly what (cnt +j) is supposed to mean. But I sure don't. We need to know everything that you know about the problem. Or have you given up on an automated solution? Are you looking to do this manually via an editor? |
|
#3
|
|||
|
|||
|
i supposed that you wanna get the following format:
111111111111111111111111 ################################### 2222222222222222222222222222222 correct? |
|
#4
|
|||
|
|||
|
Thanks for your replies.
Let me clarifiy. below is some sample data 1) abcdefghijklmnopqrstuvwxyz$ 2) abcdefghijklmno$ 3) pqrstuvwxyz$ 4) abcdefghijklmnopqrstuvwxyz$ Lines 1 and 4 are as expexted in my data file. However, lines 2 and 3 are supposed to be on one line (line 2). But, because of a new line character in the middle of the line, the row is being split. I need to devise a method to check my file where a newline character has split the line, remove the new line character, and the join (ctrl + J) lines 2 an 3 into line 2. The new line character does not occure in the same character position. It does not occur with any line frequency. I've been trying to create a script using either sed or awk to resolve the problem. This is something that needs to happen nightly and will not be a 1 time manual effort. |
|
#5
|
||||
|
||||
|
In private email, the OP told me that any line that does not start with "REQC" must be joined with the line that precedes it. This is the kind of information that we need to tackle this problem. Here is a sed script that does just that...
Code:
#! /usr/bin/sed -nf
#
#
${s/^REQC/REQC/
t final
H
b found
: final
x
s/\n//g
p
x
p
b
}
1{h
d
}
s/^REQC/REQC/
t found
H
b
: found
x
s/\n//g
p
|
||||
| Google The UNIX and Linux Forums |