我一直在想这将是获得最佳的方式很好在bash,即随机性,这将是一个过程,以获得之间的随机正整数MIN,并MAX使得
在 bash 中获得随机性的一种有效方法是使用$RANDOM变量。但是,这仅对 0 到 2 15 -1之间的值进行采样,这对于所有用途来说可能不够大。人们通常使用模数将其置于他们想要的范围内,例如,
MIN=0
MAX=12345
rnd=$(( $RANDOM % ($MAX + 1 - $MIN) + $MIN ))
Run Code Online (Sandbox Code Playgroud)
此外,这会产生偏差,除非$MAX碰巧除以 2 15 -1=32767。例如,如果$MIN是 0 并且$MAX是 9,那么值 0 到 7 的可能性比值 8 和 9 稍大,$RANDOM永远不会是 32768 或 32769。随着范围的增加,这种偏差会变得更糟,例如,如果$MIN是 0 并且$MAX是9999,那么数字 0 到 2767 的概率为4 / 32767,而数字 2768 到 9999 的概率仅为 …
出于某些调试目的,我希望能够手动将FAT32 分区的脏位设置为 true。
我发现吨关于如何使用信息fsck.vfat,以去除如何将脏位,但没有设置它。
这是可能的,因为mount它。当安装了 FAT32 分区(dirty 为 false)时,mount将dirty 设置为 true(并umount再次将其设置为 false)。我正在寻找一种在不安装分区的情况下设置脏位的方法,即模拟它没有完全卸载。
This is the weirdest thing.
In a script, I start an SSH tunnel like so:
ssh -o StrictHostkeyChecking=no -fND 8080 foo@bar
Run Code Online (Sandbox Code Playgroud)
This starts an ssh instance that goes into the background, and script execution continues. Next, I save its PID (for killing it later) by using bash's $! variable. For this to work, I append & to the ssh command even though it already goes into the background by itself (otherwise $! doesn't contain anything). Thus, for example the …