LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 598|回复: 2

怎么 [ $E < 5 ] 不能用

[复制链接]
发表于 2005-8-10 09:37:56 | 显示全部楼层 |阅读模式

  1. hua@hua:~$ E=0 ; while [ $E < 5 ] ; do ls ; E=$(($E+1)) ; done
  2. bash: 5: 没有那个文件或目录
  3. hua@hua:~$
  4. hua@hua:~$
  5. hua@hua:~$ E=0 ; while [ $E != 5 ] ; do ls ; E=$(($E+1)) ; done
  6. bin   Desktop  kid                  Mail      scrothot  win32bin
  7. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  8. bin   Desktop  kid                  Mail      scrothot  win32bin
  9. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  10. bin   Desktop  kid                  Mail      scrothot  win32bin
  11. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  12. bin   Desktop  kid                  Mail      scrothot  win32bin
  13. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  14. bin   Desktop  kid                  Mail      scrothot  win32bin
  15. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  16. hua@hua:~$
  17. hua@hua:~$
  18. hua@hua:~$ E=0 ; while [ $E -lt 5 ] ; do ls ; E=$(($E+1)) ; done
  19. bin   Desktop  kid                  Mail      scrothot  win32bin
  20. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  21. bin   Desktop  kid                  Mail      scrothot  win32bin
  22. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  23. bin   Desktop  kid                  Mail      scrothot  win32bin
  24. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  25. bin   Desktop  kid                  Mail      scrothot  win32bin
  26. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  27. bin   Desktop  kid                  Mail      scrothot  win32bin
  28. debs  goodies  lynx_bookmarks.html  Projects  tmp       Workspace
  29. hua@hua:~$                                                                                             

复制代码







help test  里都有

  1.     String operators:

  2.         -z STRING      True if string is empty.

  3.         -n STRING
  4.         STRING         True if string is not empty.

  5.         STRING1 = STRING2
  6.                        True if the strings are equal.
  7.         STRING1 != STRING2
  8.                        True if the strings are not equal.
  9.         STRING1 < STRING2
  10.                        True if STRING1 sorts before STRING2 lexicographically.
  11.         STRING1 > STRING2
  12.                        True if STRING1 sorts after STRING2 lexicographically.

复制代码


虽然不是比较大小 , 但是比较长短总可以啊
发表于 2005-8-10 09:52:10 | 显示全部楼层
需要将<转意,默认在[]中把它解释成重定向符号了!

  1. E=0 ; while   [ $E \< 5 ]  ; do  ls ; E=$(($E+1)) ; done
复制代码

这样就可以了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-10 10:16:04 | 显示全部楼层
谢谢 狼头 ~~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表