How to check if grep has no output?

前端 未结 5 1360
借酒劲吻你
借酒劲吻你 2020-12-15 03:17

So I need to check if the recipient username is in /etc/passwd which contains all the users in my class, but I have tried a few different combinations of if statements and g

5条回答
  •  时光说笑
    2020-12-15 03:29

    The -z check is for variable strings, which your grep isn't giving. To give a value from your grep command, enclose it in $():

    if [ -z $(grep $address /etc/passwd) ]
    

提交回复
热议问题