linux 管道符 列出目录中文件,放如其他命令中执行
ll tests/Feature/ | grep '^-' | awk '{print $9}' | grep '.php$' | xargs -i vendor/bin/phpunit tests/Feature/{} ll tests/Feature/ | grep '^-' | awk '{print $9}' | grep '.php$' | xargs -i vendor/bin/phpunit tests/Feature/{} function ipCode() {
$ip_long = array(
array('607649792', '608174079'), // 36.56.0.0-36.63.255.255
array('1038614528', '1039007743'), // 61.232.0.0-61.237.255.255
array('1783627776', '1784676351'), // 106.80.0.0-106.95.255.255
array('2035023872', '2035154943'), // 121.76.0.0-121.77.255.255
array('2078801920', '2079064063'), // 123.232.0.0-123.235.255.255
array('-1950089216', '-1948778497'), // 139.196.0.0-139.215.255.255
array('-1425539072', '-1425014785'), // 171.8.0.0-171.15.255.255
array('-1236271104', '-1235419137'), // 182.80.0.0-182.92.255.255
array('-770113536', '-768606209'), // 210.25.0.0-210.47.255.255
array('-569376768', '-564133889'), // 222.16.0.0-222.95.255.255
);
$rand_key = mt_rand(0, 9);
return $ip = long2ip(mt_rand($ip_long[$rand_key][0], $ip_long[$rand_key][1]));
}
分享网址:
http://www.dooccn.com/php7/#id/b68e0f6af9ba47807a24478ffdaf2684
<?php
function randNumberArray($min, $max, $count){
$res = [];
foreach (range(1, $count) as $n) {
$res[] = mt_rand($min, $max);
}
sort($res, SORT_NUMERIC);
return $res;
}
/**
* 合并秒和毫钞,并按从小到大排序
*/
function mergeTimeMillisecond($times, $milliseconds){
sort($times, SORT_NUMERIC);
$times = array_map(function ($v,$idx) use ($milliseconds) {
return $v * 1000 + ($milliseconds[$idx]??0);
}, $times, array_keys($times));
sort($times, SORT_NUMERIC);
$times = array_map(function ($v) {
$_f = explode('.', strval($v / 1000));
return [
$_f[0],
$_f[1]??0
];
}, $times, array_keys($times));
return $times;
}
function randMillisecond($count, $total, $extent=0.3){
$res = [];
$svg = $total / $count;
for($i=1;$i<$count;$i++){
$_rand = mt_rand(max(0, $svg-($svg*$extent)), min(999, $svg+($svg*$extent)));
$res[] = $_rand;
}
$end = $total - array_sum($res);
if ($end < 0) {
$end = abs($end);
foreach ($res as &$v) {
if ($v > $end) {
$v -=$end;
continue;
}
}
unset($v);
$end = 0;
}
$res[] = $end;
shuffle($res);
return $res;
}
$count = 10;
$total = intval(999 * $count * .5);
$res = randMillisecond($count, $total);
$times = randNumberArray(time() - 10, time(), 10);
$times = mergeTimeMillisecond($times, $res);
var_dump($count, $total, $res, array_sum($res), $times); 查看命令文档:
man ls按大小排序:
ll -Sh按时间排序:
ll -t默认是按降序,如要按升序可+上管道:| tac