[英]shell script to Find a particular Pattern in repetitive data a file . and add new blank line before matched pattern
我需要在文件中找到一個特定的模式,如果找到模式,然后添加一個空行並再次搜索相同的模式。
我的文件.txt
Apple_123_fruit
fruit
1
Apple_456_fruit
fruit_2
2
所以我想搜索以apple開頭的字符串,然后是*,如果找到該模式,則將以下3行添加到一行中,然后添加一個空行並再次對第二條記錄重復相同的操作。
output 應該喜歡:
Apple_123_fruit fruit 1
Apple_456_fruit fruit_2 2
任何人都可以在這里幫忙。
該算法應該有效:
我將使用確切的命令進行更新
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.