Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2003
    Posts
    2

    Question Unanswered: 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

  2. #2
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    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

  3. #3
    Join Date
    Oct 2003
    Posts
    2

    Cool It works nicely!

    Hi,

    Thank you for your help, it works nicely and it solves my problem!

Posting Permissions

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