what is wrong with my unix script

后端 未结 5 1031
温柔的废话
温柔的废话 2021-01-29 03:17
#!/bin/bash

while echo -n \"Player\'s name?\"
    read name
    [ $name != \'ZZZ\' ]
do
    searchresult=$(grep [$name] playername)
    if [ $searchresult = 0 ]
    the         


        
5条回答
  •  春和景丽
    2021-01-29 03:22

    grep returns multiple words so shell interprets the if statement as having so many tokens. If you just want to check if there was a match, do this:

    if grep "$name" playername &> /dev/null; then
        # ....
    

提交回复
热议问题