gpt4 book ai didi

string - 将多行字符串中的指定列转换为单个逗号分隔行

转载 作者:行者123 更新时间:2023-11-29 08:39:17 24 4
gpt4 key购买 nike

假设我有以下字符串:

something1:    +12.0   (some unnecessary trailing data (this must go))
something2: +15.5 (some more unnecessary trailing data)
something4: +9.0 (some other unnecessary data)
something1: +13.5 (blah blah blah)

我怎样才能把它变成简单的

+12.0,+15.5,+9.0,+13.5

在 bash 中?

最佳答案

简洁明了:

awk '{print $2}' file.txt | paste -s -d, -

关于string - 将多行字符串中的指定列转换为单个逗号分隔行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8714355/

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