Bash: One-liner to exit with the opposite status of a grep command?

后端 未结 11 2079
渐次进展
渐次进展 2021-02-06 22:08

How can I reduce the following bash script?

grep -P \"STATUS: (?!Perfect)\" recess.txt && exit 1
exit 0

It seems like I should be able

11条回答
  •  暖寄归人
    2021-02-06 22:35

    I also needed such a solution for writing puppet only if statements and came up with the following command:

    /bin/grep --quiet 'root: root@ourmasterdomain.de' /etc/aliases; if [ $? -eq 0 ]; then test 1 -eq 2; else test 1 -eq 1; fi;

提交回复
热议问题