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 > Concatenate lines given special ending characters and reverse

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-15-03, 11:06
pagechristian pagechristian is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Question Concatenate lines given special ending characters and reverse

Hi,

I am trying to concatenate lines with special ending character =, to be able to reverse the result. Example:

Original file:
KBTV 141354Z 18008KT 10SM CLR 13/06 A2993 RMK AO2 SLP136 T01330061 =
KBTV 141454Z 20009KT 10SM FEW120 15/06 A2990 RMK AO2 SLP126 ACSL S-N T01500061
58018 =
KBTV 141554Z 17010KT 10SM FEW120 17/06 A2987 RMK AO2 SLP114 ACC DSNT SW ACSL
ALQDS T01720056 =
KBTV 141654Z 19011G19KT 10SM SCT120 18/06 A2984 RMK AO2 SLP105 ACC W ACSL ALQDS
T01780061 =

I want to concatenate lines beginning with KBTV up to the line ending with a =
Is there a way to do that using sed or awk?

Thanks

Christian
Reply With Quote
  #2 (permalink)  
Old 10-15-03, 18:31
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Lightbulb

try this:

awk '{if ( $1 == "KBTV" ) rec = $0; else rec = rec $0;
if ( $NF == "=" ) print rec;}' OrigFile.txt >NewFile.txt

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 10-16-03, 14:41
pagechristian pagechristian is offline
Registered User
 
Join Date: Oct 2003
Posts: 2
Cool It works nicely!

Hi,

Thank you for your help, it works nicely and it solves my problem!
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