原文写于2010-11-03 18:29:20,网易博客,已删.
     要在shell中生成随机数,在bash中可以调用$RANDOM,引用一段对RANDOM的介绍.
     Each time this is referenced, a random integer between 0 and 32767 is generated. The sequence of random numbers may be initialized by assigning a value to RANDOM. If RANDOM is unset, it loses its special properties, even if it is subsequently reset.
     要生成一个范围中的随机数,可以用:
        declare -i randomnum=$RANDOM*$scale/32767
     同样,要使用declare,必须是在bash环境中.

     2011-07-02 补充:
     shell第一行必须是#!/usr/bin/bash

相关文章:

  • 2022-02-11
  • 2021-09-25
  • 2022-02-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
猜你喜欢
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案