gpt4 book ai didi

linux - 对字符串后的数字求和

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:09:19 24 4
gpt4 key购买 nike

我将以下数据存储在一个文件中:

number1:0 number2=1 minnumber2number3:1 minnumber3:0 minnumber4:0 maxnumber2number3:1 maxnumber3:0 maxnumber4:0 no. of number5 per bucket:35 num:
number1:0 number2=0 minnumber2number3:3 minnumber3:3 minnumber4:11577215 maxnumber2number3:3 maxnumber3:3 maxnumber4:14707215 no. of number5 per bucket:6 num:
number1:0 number2=1 minnumber2number3:1 minnumber3:0 minnumber4:0 maxnumber2number3:3 maxnumber3:1 maxnumber4:1882188 no. of number5 per bucket:8 num:
number1:0 number2=1 minnumber2number3:2 minnumber3:248 minnumber4:10000000 maxnumber2number3:2 maxnumber3:248 maxnumber4:10000000 no. of number5 per bucket:91 num:
number1:0 number2=1 minnumber2number3:2 minnumber3:239 minnumber4:11641499 maxnumber2number3:2 maxnumber3:244 maxnumber4:2248700 no. of number5 per bucket:8999 num:
number1:0 number2=1 minnumber2number3:2 minnumber3:251 minnumber4:2000000 maxnumber2number3:2 maxnumber3:251 maxnumber4:2000000 no. of number5 per bucket:8986 num:
number1:0 number2=1 minnumber2number3:2 minnumber3:232 minnumber4:14775115 maxnumber2number3:1 maxnumber3:0 maxnumber4:0 no. of number5 per bucket:6385 num:
number1:0 number2=1 minnumber2number3:2 minnumber3:253 minnumber4:9404695 maxnumber2number3:1 maxnumber3:0 maxnumber4:0 no. of number5 per bucket:8863 num:
number1:0 number2=1 minnumber2number3:3 minnumber3:3 minnumber4:14777215 maxnumber2number3:1 maxnumber3:0 maxnumber4:0 no. of number5 per bucket:2679 num:

现在我需要检索“每个桶的编号 5:”之后的所有数字并将它们相加。例如,我需要总结以下内容:

35 
6
8
91
8999
8986
6385
8863
2679

我知道我可以使用像 python 这样的编程语言来做同样的事情,但是我正在学习 linux 命令是否有一些 linux 命令,比如 grep 等,可以帮助我做同样的事情。

最佳答案

你可以试试sed:

sed -e 's/^.*bucket://' | sed -e 's/[a-zA-Z]*:$//'

关于linux - 对字符串后的数字求和,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30658202/

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