Skip to content

Commit

Permalink
updated сalc and сity validators
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyasadkin committed Feb 16, 2024
1 parent d4020b3 commit 813b979
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions calc.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/bash

if [ $# -ne 2 ]; then
echo "Дай мне два числа, которые разделены пробелом :)"
echo "Дай мне два числа, разделенные пробелом :)"
exit
fi

num1=$(echo "$1" | sed 's/,/./')

num2=$(echo "$2" | sed 's/,/./')

if ! [[ $num1 =~ ^-?[0-9]+(\.[0-9]+)?$ ]] || ! [[ $num2 =~ ^-?[0-9]+(\.[0-9]+)?$ ]]; then
echo "Мне не удалось распознать передаваемые числа :("
if ! [[ $num1 =~ ^[-+]?[0-9]+(\.[0-9]+)?$ ]] || ! [[ $num2 =~ ^[-+]?[0-9]+(\.[0-9]+)?$ ]]; then
echo "Мне не удалось разобрать один из передаваемых аргументов :("
exit
fi

Expand Down
9 changes: 7 additions & 2 deletions city.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#!/bin/bash

if [ ! -f "$1" ]; then
echo "Мне не удалось найти передаваемый файл."
exit
fi

if [ -z $2 ]; then
count=3
count=3
else
count=$2
count=$2
fi

cat $1 | tail -n +2 | awk '{print $3}' | grep -v '^$'| sort | uniq | while read city; do
Expand Down

0 comments on commit 813b979

Please sign in to comment.