i< =:表达式不完整;更多令牌预期。 KSH [英] i<=: Expression is not complete; more tokens expected. ksh

查看:263
本文介绍了i< =:表达式不完整;更多令牌预期。 KSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到这个错误: i< =:表达式不完整; 这是代码:

i get this error: i<=: Expression is not complete; more tokens expected. This is the code:

vr=`$line`
set sep_mx=`echo $vr | awk '{
    n=split($0,x,"@#;")
    print n
}'`

echo $sep_mx
i=1 && while ((i<=$sep_mx))
do                                       
    echo $vr | awk -v er=$i '{
         n=split($0,x,"@#;")
         print x[er]
    }'
    ((i+=1))
done

任何人都可以帮助我?谢谢

Anyone can help me? Thanks

推荐答案

为了回答原来的问题,错误信息已经
解释错误发生的位置:

To answer the original question, the error message already explains where the error occurs:

i <= $ / code> i <=:表达式未完成; 是扩展((i <= $ sep_mx))的内容的结果。

In i<= in i<=: Expression is not complete; more tokens expected. is the result of the expansion of the contents of ((i<=$sep_mx)).

如果 $ sep_mx 包含一个空字符串,则这将是

This would happen if $sep_mx contained an empty string, which in turn, would be the consequence of

vr=`$line`

导致一个 vr ,它不包含您在awk行中的split()函数中包含的分隔符字符串。

resulting in a vr that does not contain the delimiter string you include in the split() function in the awk line.

请注意,awk split()的第三个参数是正则表达式。如果要拆分@#;中的任何字符,您应该将其包含在方括号中。

Note that awk split()'s third argument is a regular expression. If you want to split on any of the characters in "@#;", you should turn it into a character set by enclosing it in square brackets.

比较: / p>

Compare:

$ echo "@fee#fie@foe" | awk '{ print split($0,x,"[@#;]") }'
4

With:

$ echo "@fee#fie@foe" | awk '{ print split($0,x,"@#;") }'
1

这篇关于i&lt; =:表达式不完整;更多令牌预期。 KSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆