Linux 内でシェル スクリプトを作成するのは初めてで、ユーザーから任意の 3 つの数字を取得して昇順で表示できるようにしたいと考えています。昇順ではなく降順で取得できました。
コードにどのような変更を加える必要があるか教えてもらえますか? また、これを非効率的に行っている場合は、そのことを教えてください。私はできる限り多くのことを学ぼうとしています。
ありがとうございました!
#!/bin/bash
#Accepts 3 numbers and displays the number in ascending order
echo "Enter the first number"
read num1
echo "Enter the second number"
read num2
echo "Enter the third number"
read num3
allNumbers="$num1 $num2 $num3"
echo $allNumbers|tr " " "\n"|sort|tr "\n" " "