INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

join two lines

join two lines

(OP)
similar to thread822-1378654: Join 2 lines, but my keyword is on the 2nd line.
Sample Data:
15 EL01-007-CUST-SAVACCT-1 REDEFINES EL01-EVENT-DATA.
20 EL01-007-FR-CUST-SAV1
PIC X(17).
20 EL01-007-TO-CUST-SAV1
PIC X(17).
20 FILLER PIC X(416).
15 EL01-008-CUST-VERID REDEFINES EL01-EVENT-DATA.
20 EL01-008-FR-CUST-VERID
PIC X(15).
20 EL01-008-TO-CUST-VERID
PIC X(15).
20 FILLER PIC X(420).

Problem: If a line starts with PIC, I want to join it to the previous line. However, if the PIC is not first (like the FILLER lines, do nothing. If no PIC in the line, do nothing. This file is 12k lines, so not practical to do manually.
Thanks for the help getting started.

==================================
The trouble with doing something right the first time is that nobody appreciates how difficult it was - Steven Wright


RE: join two lines



Try this:

CODE

awk '$1=="PIC"{print ll" "$0; next} substr($0,length($0),1)=="." {print $0;next}{ll=$0}' cobdata.txt 
3eyes

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close