typora/note/Shell/影响shell程序的内置命令.md
2024-12-12 10:48:55 +08:00

351 B

  • exit 退出程序
  • continue 进行下一次循环
  • break 退出循环
  • shift 输入参数位移
#! /bin/env bash

sum=0
for i
do
	let sum+=$i
done
echo $sum
#! /bin/env bash

sum=0
while [ $# -ne 0 ]
do
	let sum+=$1
	shift
done
echo $sum
#! /bin/env bash

sum=0
while [ $# -ne 0 ]
do
	let sum+=$1
	shift 2
done
echo $sum