Gau*_*Rai 1 unix syntax bash shell for-loop
当我使用for像 for i in 1 2 3 4 5 那么我的文件包含
for
for i in 1 2 3 4 5
#!/bin/sh 在顶部
#!/bin/sh
但是当我使用for(( i = 0; i<=5; i++))它时它显示错误
for(( i = 0; i<=5; i++))
Syntax error: Bad for loop variable
当我删除shebang时正常运行.
请告诉我背后的原因.
anu*_*ava 5
你需要使用BASH运行,所以使用BASH shebang:
#!/bin/bash
由于arithmetic BASH loop syntax不支持older bourne shell:
arithmetic BASH loop syntax
older bourne shell
for ((i = 0; i<=5; i++)); do echo "$i" done
归档时间:
12 年 前
查看次数:
100 次
最近记录: