我有一个充满用户名的文件,我想使用 sed 将用户名更改为,PLAYER 1-20
我该如何使用 bash 脚本和 sed 在增加的同时执行此操作?
我目前有这个:
NAME=$(grep -q 'Seat' ${POKER_HAND} | awk '{print $3}')
POKER_HAND=/vagrant/sample.txt #Change to your file name
OUTPUT_FILE=/vagrant/poker-output.txt #Change where you want to output
if grep -q "${NAME}" "${POKER_HAND}"; then
sed -r "s/${NAME}/PLAYER/g" ${POKER_HAND} > file.txt
fi
Sample.txt
:
PokerStars Hand #241801691187: Hold'em No Limit ($0.05/$0.10 USD) - 2023/02/12 19:59:19 ET
Table 'Alcathous' 6-max Seat #3 is the button
Seat 1: lladnar1130 ($9.73 in chips)
Seat 3: javier_jia ($10 in chips)
Seat 5: C.Luz7 ($22 in chips)
Seat 6: calojoai4 ($11.55 in chips)
C.Luz7: posts small blind $0.05
calojoai4: posts big blind $0.10
*** HOLE CARDS ***
lladnar1130: folds
javier_jia: raises $0.14 to $0.24
C.Luz7: folds
calojoai4: folds
Uncalled bet ($0.14) returned to javier_jia
javier_jia collected $0.25 from pot
javier_jia: doesn't show hand
*** SUMMARY ***
Total pot $0.25 | Rake $0
Seat 1: lladnar1130 folded before Flop (didn't bet)
Seat 3: javier_jia (button) collected ($0.25)
Seat 5: C.Luz7 (small blind) folded before Flop
Seat 6: calojoai4 (big blind) folded before Flop
Bash 脚本解析后应该做什么:
PokerStars Hand #241801691187: Hold'em No Limit ($0.05/$0.10 USD) - 2023/02/12 19:59:19 ET
Table 'Alcathous' 6-max Seat #3 is the button
Seat 1: Player1 ($9.73 in chips)
Seat 3: Player2 ($10 in chips)
Seat 5: Player3 ($22 in chips)
Seat 6: Player4 ($11.55 in chips)
Player3: posts small blind $0.05
Player4: posts big blind $0.10
*** HOLE CARDS ***
Player1: folds
Player2: raises $0.14 to $0.24
Player3: folds
Player4: folds
Uncalled bet ($0.14) returned to Player2
Player2 collected $0.25 from pot
Player2: doesn't show hand
*** SUMMARY ***
Total pot $0.25 | Rake $0
Seat 1: Player1 folded before Flop (didn't bet)
Seat 3: Player2 (button) collected ($0.25)
Seat 5: Player3 (small blind) folded before Flop
Seat 6: Player4 (big blind) folded before Flop