shell 的奇怪行为

发布于 2024-09-25 23:39:15 字数 843 浏览 0 评论 0原文

大家好我有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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

傲世九天 2024-10-02 23:39:15

我找到了:set line1 = ($line2) 正确答案

I found it: set line1 = ($line2) right answer

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文