Bash show charcaters if not in string

前端 未结 2 632
情话喂你
情话喂你 2021-01-15 22:08

I am trying out bash, and I am trying to make a simple hangman game now.

Everything is working but I don\'t understand how to do one thing:

I am showing the

2条回答
  •  野的像风
    2021-01-15 22:43

    You don't show what you tried, but parameter expansion works fine.

    $ alphabet=abcdefghijklmnopqrstuvwxyz
    $ word="hello world"
    $ guesses=aetl
    $ echo "${word//[^[:space:]$guesses]/*}"
    *ell* ***l*
    $ echo "${alphabet//[$guesses]/*}"
    *bcd*fghijk*mnopqrs*uvwxyz
    

提交回复
热议问题