![将每个部分转换为单行](https://linux22.com/image/1575406/%E5%B0%86%E6%AF%8F%E4%B8%AA%E9%83%A8%E5%88%86%E8%BD%AC%E6%8D%A2%E4%B8%BA%E5%8D%95%E8%A1%8C.png)
我有如下所示的数据。我想将其转换为每部分一行(以 # 开头)。
我想要的是:
#6536 - NEW [R] - *NONE*.
communicationFailureEvent - SITE - MSC_MR1_B02_KBN1(55/JANPAT4-1/D311-CE/DEL-ODM_L): 55 SITE - 15/04/2018 11:21:55.
[0] Last RSL Link Failure - FMIC - Critical -/-.
Config Tag 1
#7811 - NEW [R] - *NONE*.
communicationFailureEvent - SITE - MSC_MR1_B17_KB3(8/PNB_3G/D323-CE/DEL-IBM_L): 8 SITE - 25/04/2018 15:52:04.
[0] Last RSL Link Failure - FMIC - Critical -/-.
Config Tag 3ed1
#5569 - NEW [R] - *NONE*.
communicationFailureEvent - SITE - MSC_MR1_B22_GZBD2(49/TRISHUL-APT_3G/D441-GZ/GZB): 49 SITE - 23/06/2018 08:28:54.
[0] Last RSL Link Failure - FMIC - Critical -/-.
Config Tag 86d217
#3369 - NEW [R] - *NONE*.
communicationFailureEvent - SITE - MSC_KB1_B13_KB2(19/KIRTI-NAGAR_3G/D342-EA/DEL): 19 SITE - 30/06/2018 11:06:41.
[0] Last RSL Link Failure - FMIC - Critical -/-.
Config Tag 82cb8c
#1641 - NEW [R] - *NONE*.
communicationFailureEvent - SITE - MSC_KB1_B06_KB1(27/MOTINAGAR-NW_3G/D342-EA/DEL): 27 SITE - 30/06/2018 12:08:59.
[0] Last RSL Link Failure - FMIC - Critical -/-.
Config Tag 8540f6
===========================================================
#6536 NEW [R] *NONE*. communicationFailureEvent SITE MSC_MR1_B02_KBN1(55/JANPAT4-1/D311-CE/DEL-ODM_L): 55 SITE 15/04/2018 11:21:55. [0] Last RSL Link Failure FMIC Critical -/-. Config Tag 1
答案1
假设它总是由 5 行组成:
paste -s -d ' \n' data
paste -s
连接单个文件中的所有行,插入分隔符(如果指定)-d
- 分隔符是单个字符,如果有多个字符,则每次添加一行时都会以循环方式使用它们