From e4666df35829333aae515a47c19483731d2fa0b9 Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Sun, 13 Oct 2024 21:13:20 +0200 Subject: [PATCH] make outputs even more Kik compliant --- lab1/2.bash | 2 +- lab1/3.bash | 4 ++-- lab1/6.bash | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lab1/2.bash b/lab1/2.bash index f585a90..11b858d 100755 --- a/lab1/2.bash +++ b/lab1/2.bash @@ -1,3 +1,3 @@ #!/usr/bin/env bash -grep -Roh '\w*' "$1" | sort | uniq -c | sort -nr +grep -Roh '\w*' "$1" | sort | uniq -c diff --git a/lab1/3.bash b/lab1/3.bash index e9e7b5f..0a10790 100755 --- a/lab1/3.bash +++ b/lab1/3.bash @@ -2,5 +2,5 @@ for word in $(grep -Roh '\w*' "$1" | sort | uniq) do - echo "$(grep -lRw "$word" "$1" | wc -l) $word" -done | sort -r + echo "$word: $(grep -lRw "$word" "$1" | wc -l)" +done | sort -n diff --git a/lab1/6.bash b/lab1/6.bash index c4d98c3..e233b1b 100755 --- a/lab1/6.bash +++ b/lab1/6.bash @@ -2,6 +2,6 @@ for word in $(grep -Roh '\w*' "$1" | sort | uniq) do - occurences=$(grep -REn "($word.*){2}" "$1") + occurences=$(grep -REn ".*\b$word\b.*\b$word\b.*" "$1") [ -n "$occurences" ] && printf '%s:\n%s\n' "$word" "$occurences" done