shell 中报出'$int' not a valid identifier?

shell 中报出'$int' not a valid identifier


慕的地8271018
浏览 1066回答 5
5回答

杨魅力

for $int1 in 1,2,3,4,5改为for int1 in 1 2 3 4 5变量只有取值的时候才在前面加$符号in 后面的集合以空格分隔。当然,整数序列也可以用seq命令来自动产生,如:for int1 in `seq 5`

神不在的星期二

for i in 1 2 3 4 5; do echo $i; done;应该是这样。#!/bin/bashint1 = 1for int1 in 1,2,3,4,5dosq = `expr $int1\*$int1`echo $sqdone额,可能还有问题。总之请先读Bash入门。

函数式编程

xiehuahere写的很仔细,代码如下,已测试for int1 in 1 2 3 4 5dosq=`expr $int1 \* $int1`echo $sqdone

幕布斯7119047

1.检查~/.profile 或 .bash_profile 里的PATH变量,把 /usr/ccs/bin:/usr/openwin 改成正确的路径。或者直接删除。把022 变量也删除。2.还可以直接使用echo $PATH 查看。通过 export PATH=.... 来设置。解析:可能是oracle 用户目录下的profile 的PATH 变量 设置不合理造成的。ls ~/.*profile*就可以找到profile 文件。补充:~ 指 系统的oracle 用户默认路径。例如:/home/oracle或者 /usr/lib/oracle/xecat /etc/passwd |grep -i oracleoracle:x:1004:1002::/usr/lib/oracle/xe:/bin/bash
打开App,查看更多内容
随时随地看视频慕课网APP