shell 的奇怪行为
大家好我有3个文件: 用于输入的引擎脚本
#! /bin/tcsh -f
cat $1 |./hello
hello 脚本
#! /bin/tcsh -f
set line1 = ($<)
while (${#line1} != 0)
set line2 = ($<)
set first1 = $line1[1]
set first2 = $line2[1]
if( $first1 == $first2) then
echo $first1 $line1[2] $line2[2]
set line1 = ($<)
else
echo $first1 $line1[2] 0
set line1 = $line2 <- problem here, but why?
endif
end
文件
mba 30
mba 70
er 10
er 90
ma 20
ma 80
mt 100
al 35
al 65
eg 100
el 100
ez 10
ez 90
an 100
ews 30
rews 70
ar 23
ar 77
esa 45
esa 55
我的脚本似乎是正确的,但我收到一个错误:
mba 30 70
er 10 90
ma 20 80
mt 100 0
set: Variable name must begin with a letter.
有什么想法吗? 提前致谢
hello everyone I have 3 files:
engine script
#! /bin/tcsh -f
cat $1 |./hello
hello script
#! /bin/tcsh -f
set line1 = (lt;)
while (${#line1} != 0)
set line2 = (lt;)
set first1 = $line1[1]
set first2 = $line2[1]
if( $first1 == $first2) then
echo $first1 $line1[2] $line2[2]
set line1 = (lt;)
else
echo $first1 $line1[2] 0
set line1 = $line2 <- problem here, but why?
endif
end
file for input
mba 30
mba 70
er 10
er 90
ma 20
ma 80
mt 100
al 35
al 65
eg 100
el 100
ez 10
ez 90
an 100
ews 30
rews 70
ar 23
ar 77
esa 45
esa 55
my script seems to be right but I receive an error:
mba 30 70
er 10 90
ma 20 80
mt 100 0
set: Variable name must begin with a letter.
any ideas why?
thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了:
set line1 = ($line2)
正确答案I found it:
set line1 = ($line2)
right answer