История изменений
Исправление derlafff, (текущая версия) :
Не благодари:
young=''
middle=''
old=''
while read name && [ "$name" != '12345' ] && read age; do
if [ "$age" -le 18 ]; then
young="$young $name"
elif [ "$age" -le 45 ]; then
middle="$middle $name"
else
old="$old $name"
fi
done
for type in young middle old; do
echo $type:
eval "echo \$$type | tr ' ' '\n'"
done
echo old count: $(echo $old | wc -w)
На работоспособность не проверял
//проверил, работает. bash скушал мой мозг -_-
Исправление derlafff, :
Не благодари:
young=''
middle=''
old=''
while read name && [ "$name" != '12345' ] && read age; do
if [ "$age" -le 18 ]; then
young="$young $name"
elif [ "$age" -le 45 ]; then
middle="$middle $name"
else
old="$old $name"
fi
done
for type in young middle old; do
echo $type:
eval "echo \$$type | tr ' ' '\n'"
done
echo old count: $(echo $old | wc -w)
На работоспособность не проверял
Исправление derlafff, :
Не благодари:
young=''
middle=''
old=''
while read name && [ "$name" != '12345' ] && read age; do
if [ "$age" -le 18 ]; then
young="$young $name"
elif [ "$age" -le 45 ]; then
middle="$middle $name"
else
old="$old $name"
fi
done
for type in young middle old; do
echo $type:
eval "echo \$$type | tr ' ' '\n'"
done
На работоспособность не проверял
Исходная версия derlafff, :
Не благодари:
young=''
middle=''
old=''
while read name && [ "$name" != '12345' ] && read age; do
if [ "$age" -le 18 ]; then
young="$young $name"
elif [ "$age" -le 45 ]; then
middle="$middle $name"
else
old="$old $name"
fi
done
for type in young middle old; do
echo $type:
eval "echo \$$type | tr ' ' '\n'"
done
На работоспособность не проверял