The line content of the keyword SEM is appended to the beginning of the next keyword SEM

Source: Internet
Author: User

Problem:

Matches the line contents of the keyword SEM, appended to the beginning of the next keyword SEM

Text
SEM 1234
Point 23 33
Point AA
Point SD
Point FD
SEM 5412
Point TT
Point OQ
Point-IW
SEM 4513
Point 142 IWS
Point 142 AMX


Effect

SEM 1234 Point 23 33
SEM 1234 point AA
SEM 1234 point SD
SEM 1234 Point FD
SEM 5412 Point-TT
SEM 5412 point OQ
SEM 5412 Point-IW
SEM 4513 point 142 IWS
SEM 4513 Point 142 AMX


Answer:

awk '!/^sem/{print a,$0}/^sem/{a=$0} ' file

SEM 1234 Point 23 33

SEM 1234 point AA

SEM 1234 point SD

SEM 1234 Point FD

SEM 5412 Point-TT

SEM 5412 point OQ

SEM 5412 Point-IW

SEM 4513 point 142 IWS

SEM 4513 Point 142 AMX


This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1773793

The line content of the keyword SEM is appended to the beginning of the next keyword SEM

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.