From ce191006c6c76df7158e28bb5e5ee95d1399e66e Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 17 Feb 2021 09:35:05 -0500 Subject: [PATCH] Manage empty results. --- 27-01-2021-grepString/grepHttp.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/27-01-2021-grepString/grepHttp.sh b/27-01-2021-grepString/grepHttp.sh index 6879405..b1d0834 100644 --- a/27-01-2021-grepString/grepHttp.sh +++ b/27-01-2021-grepString/grepHttp.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash -out=`find . -name '*.java' -exec grep 'http://' /dev/null {} +` -echo "${out}" -if [[ -n "${out}" && "$(grep '\.java' <<< ${out})" ]]; then +out=`find . -name '*.java' -exec grep 'http://' /dev/null {} + || echo 'empty'` +if [[ ["${out}" != "empty"] && "$(grep '\.java' <<< ${out})" ]]; then + echo "${out}" echo "HTTP protocol found" else echo "HTTP protocol not found"