gpt4 book ai didi

bash - 根据文件输出创建名称/值对

转载 作者:行者123 更新时间:2023-11-29 09:43:44 24 4
gpt4 key购买 nike

我想将 cat myFile.txt 的输出格式化为以下格式:

app1=19
app2=7
app3=20
app4=19

通过各种命令使用管道输出的某种组合。
实现此目标的最简单方法是什么?
我试过使用 cut -f2 但这并没有改变输出,这很奇怪。

这是基本的命令/文件输出:

[user@hostname ~]$ cat myFile.txt
1402483560882 app1 19
1402483560882 app2 7
1402483560882 app3 20
1402483560882 app4 19

最佳答案

根据您的输入:

awk '{ print $2 "=" $3 }' myFile

输出

app1=19
app2=7
app3=20
app4=19

关于bash - 根据文件输出创建名称/值对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24161900/

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