数値比較

#!/bin/bash

read -p "Number? " n
if ((n > 10)); then
	echo "bigger than 10"
fi

[vagrant@localhost shell]$ sed -i ‘s/\r//’ hello
[vagrant@localhost shell]$ ./hello
Number? 12
bigger than 10

#!/bin/bash

for i in {1..5};
do
	echo $i
done

#!/bin/bash

for ((i=1; i<10; i++)); do echo $i done [/code] [code] #!/bin/bash for item in $(date); do echo $item done [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello 2018年 9月 30日 日曜日 12:11:36 JST [code] #!/bin/bash i=1 while read line; do echo $i "$line" ((i++)) done < colors.txt [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello 1 red 2 blue [code] #!/bin/bash read -p "Signal color? " color case "$color" in red) echo "stop" ;; blue) echo "go" ;; yello) echo "caution" ;; *) echo "wrong signal" esac [/code] [vagrant@localhost shell]$ sed -i 's/\r//' hello [vagrant@localhost shell]$ ./hello Signal color? red stop