The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


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 !!

More UNIX and Linux Forum Topics You Might Find Helpful
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

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-21-2002
Registered User
 

Join Date: Jun 2002
Location: Myrtle Beach, Sc
Posts: 2
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  
Old 06-22-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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  
Old 06-22-2002
Registered User
 

Join Date: Jun 2002
Posts: 50
i supposed that you wanna get the following format:

111111111111111111111111
###################################
2222222222222222222222222222222

correct?
  #4  
Old 06-24-2002
Registered User
 

Join Date: Jun 2002
Location: Myrtle Beach, Sc
Posts: 2
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  
Old 06-26-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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
Please take the time to define your problem carefully. We can't solve problems that we don't understand.
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:37 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0