较新的编码不确定这是否是管理项目变量的正确方法有人可以帮助我吗?

较新的编码不确定这是否是管理项目变量的正确方法有人可以帮助我吗?

这是日志(我只包含了匹配的行,实际日志中还有很多其他内容)

/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.06-17.30.30:443][570]PavlovLog: TicketValidation succeed for: 76561198149279501 Saltheili
/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.06-20.56.45:053][555]PavlovLog: TicketValidation succeed for: 76561198041336824 Lumenero
/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.06-22.22.12:299][270]PavlovLog: TicketValidation succeed for: 76561198345598849 GusRemington
/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.07-02.03.19:386][ 55]PavlovLog: TicketValidation succeed for: 76561198302880912 Snitchhy
/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.07-02.40.29:749][786]PavlovLog: TicketValidation succeed for: 76561198291769546 Jupiter
/home/steam/pavlovserver/Pavlov/Saved/Logs/Pavlov-backup-2021.07.07-08.51.08.log:[2021.07.07-03.38.14:208][307]PavlovLog: TicketValidation succeed for: 76561198220506681 Fedora

我正在尝试提取信息并使用它设置变量

id=($(grep  'TicketValidation'  ~/pavlovserver/Pavlov/Saved/Logs/* | cut -b 153-170))
date=($(grep  'TicketValidation'  ~/pavlovserver/Pavlov/Saved/Logs/* | cut -b 58-67))
name=($(grep  'TicketValidation'  ~/pavlovserver/Pavlov/Saved/Logs/* | cut -b 171-270)

这是我想要的格式

$date PlayerName; $name PlayersID; $id

但是我在将它放在 1 行上时遇到了问题,我正试图将它发送到数组,我需要添加[*]某处吗?

如果我运行echo ${id[@]}

76561198149279501 76561198041336824 76561198345598849 76561198302880912 76561198291769546 76561198220506681

这看起来是正确的,但在名字上我只得到了这个 echo ${name[@]}

 Fedorarygton

如果我运行$ grep **'TicketValidation' ~/pavlovserver/Pavlov/Saved/Logs/* | cut -b 171-270 (来自 $name var 的 grep)

我明白

Saltheili
Lumenero
GusRemington
Snitchhy
Jupiter
Fedora

有想法吗?

相关内容