Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
任何人都可以告诉我会出现什么问题?我知道这是一个半秒的问题,但请帮助:)egrep "first" a.sh && egrep "second" a.sh有效,a.sh 包含第一、第二、第三等。谢谢!
egrep "first" a.sh && egrep "second" a.sh
if [[ egrep "first" a.sh && egrep "second" a.sh ]]; then echo "success" fi
您的问题是您正在使用该[[命令。只使用 greps。
[[
if egrep ... && egrep ... ; then
我认为这可能是你想要做的:
found_1=$(egrep "first" a.sh) found_2=$(egrep "second" a.sh) if [[ -n "$found_1" ]] && [[ -n "$found_2" ]]; then echo "success" fi