From 324ecd76cecce01b8db32ef8188a0ec8d2ccb9ff Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Fri, 11 Oct 2024 11:55:34 +0200 Subject: [PATCH] make command output more Kik compliant --- lab1/4.bash | 4 ++-- lab1/6.bash | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lab1/4.bash b/lab1/4.bash index 8e99c98..3ff4df3 100755 --- a/lab1/4.bash +++ b/lab1/4.bash @@ -2,6 +2,6 @@ for word in $(grep -Roh '\w*' "$1" | sort | uniq) do - echo "current word: $word" - grep -Rw "$word" "$1" + echo "$word:" + grep -Rwn "$word" "$1" done diff --git a/lab1/6.bash b/lab1/6.bash index 1d1281e..c4d98c3 100755 --- a/lab1/6.bash +++ b/lab1/6.bash @@ -2,6 +2,6 @@ for word in $(grep -Roh '\w*' "$1" | sort | uniq) do - echo "current word: $word" - grep -RE "($word.*){2}" "$1" + occurences=$(grep -REn "($word.*){2}" "$1") + [ -n "$occurences" ] && printf '%s:\n%s\n' "$word" "$occurences" done