gpt4 book ai didi

linux - Bash text multi line into one line with spec.数据

转载 作者:太空宇宙 更新时间:2023-11-04 12:29:15 25 4
gpt4 key购买 nike

我有这样的东西

Title  : Magic Moments                   Artist: Perry Como
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 7

我需要这个

Magic Moments,Perry Como,Original American Songbook: 50,2005,Other (12),DrBN,7

我是 bash 的新手,我不知道如何获得它感谢您的帮助!

编辑

Title  : Magic Moments                   Artist: Perry Como                    
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 7
Title : Stormy Weather Artist: Frank Sinatra
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 8
Title : Let There Be Love Artist: Sammy Davis, Jr.
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 9
Title : Makin' Whoopee Artist: Esther Williams
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 10
Title : Spanish Eyes Artist: Al Martino
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 11
Title : 'S Wonderful {From An American Artist: Gene Kelly; Georges Guétary
Album : Original American Songbook: 50 Year: 2005, Genre: Other (12)
Comment: DrBN Track: 12
Title : Out Of My Head Artist: John Newman
Album : Tribute (Deluxe Edition) Year: 2013, Genre: Pop (13)
Comment: no coment Track: 6

最佳答案

使用sedpaste,如

sed 's/Title *: //;s/ *Artist: /,/;s/Album *: //; s/ *Year: /,/;s/ *Genre: //;s/Comment: //;s/ *Track: /,/' | paste -sd,

当然,如果你有多个记录/专辑/轨道,或者字段名称可能会发生变化,还有更好的解决方案。

关于linux - Bash text multi line into one line with spec.数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43759293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com