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