diff --git a/sum.sh b/sum.sh new file mode 100755 index 000000000..1768aa5a7 --- /dev/null +++ b/sum.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +if [ "$#" -ne 2 ]; then + echo "Ошибка: требуется два аргумента" + exit 1 +fi + +numReg="^-?[0-9]+([.][0-9]+)?$" + +if ! [[ $1 =~ $numReg && $2 =~ $numReg ]]; then + echo "Введите корректные числа" + exit 1 +fi + + +result=$(awk "BEGIN {print $1 + $2}") + +echo "Результат сложения $1 + $2 = $result" diff --git a/users.sh b/users.sh new file mode 100755 index 000000000..200cbc796 --- /dev/null +++ b/users.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + + +awk '{print $3}' users.txt | sort | uniq -c | sort -nr | head -n 3 \ No newline at end of file diff --git a/users.txt b/users.txt new file mode 100644 index 000000000..ee87ff762 --- /dev/null +++ b/users.txt @@ -0,0 +1,6 @@ +id user city phone +1 test Moscow 1234123 +2 test2 Saint-P 1232121 +3 test3 Tver 4352124 +4 test4 Milan 7990923 +5 test5 Moscow 908213 \ No newline at end of file