不惑: shell函数中可以使用return语句提前返回 疑惑:有些shell脚本中,函数外也会出现retur …
作者存档:phpor
php 获取数组中前N个值
如下,获取数组中的前2个元素:
1 2 3 4 5 6 |
bash-4.1# php -r 'print_r(array_chunk(array('a'=>1,'b'=>2,'c'=>3),2,true)[0]);' Array ( [a] => 1 [b] => 2 ) |
难道还有更方 …
bash 小知识之 dubble dash
先看两个例子: basename 和 printf 都是常用的命令,怎么还能出问题? 对于shell来讲,参数 …
文件copy之断点copy
下载文件时,最好有断点续传的功能,免得下载了一部分断掉了导致前功尽弃,curl就支持断点续传; 文件copy时 …
移动硬盘测速
https://item.jd.com/1179011.html 读速度: 60MB/s 写速度 …
linux 下载工具之 aria
有一种文件下载方式为: 把知道的下载源都组织到一个文件中(metalink,扩展名 meta4),这些下载源可 …
多台机器上批量执行ssh命令的小脚本
脚本:
1 2 3 4 5 6 7 8 9 10 |
#!/bin/bash #name mssh.sh #usage: ./mssh.sh host-1 host-2 host-3 'cmd' cmd="${@: -1}" #取最后一个参数,这里冒号后面的空格不能省略 hosts=("$@") for ((i=0; i < $# - 1; i++)) ;do host=${hosts[$i]} echo "#@$host" echo ssh $host "$cmd" done |
用法: [crayon …
关于nsenter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# nsenter -h 用法: nsenter [options] <program> [<argument>...] Run a program with namespaces of other processes. 选项: -t, --target <pid> 要获取名字空间的目标进程 -m, --mount[=<file>] enter mount namespace -u, --uts[=<file>] enter UTS namespace (hostname etc) -i, --ipc[=<file>] enter System V IPC namespace -n, --net[=<file>] enter network namespace -p, --pid[=<file>] enter pid namespace -U, --user[=<file>] enter user namespace -S, --setuid <uid> set uid in entered namespace -G, --setgid <gid> set gid in entered namespace --preserve-credentials do not touch uids or gids -r, --root[=<dir>] set the root directory -w, --wd[=<dir>] set the working directory -F, --no-fork 执行 <程序> 前不 fork -Z, --follow-context set SELinux context according to --target PID -h, --help 显示此帮助并退出 -V, --version 输出版本信息并退出 更多信息请参阅 nsenter(1)。 |
从 help 来看,只要使用了 -p 选项, …
syslog协议之PRI解析
syslog协议的第一部分是尖括号引用的一个数字,如: <182> 该数字大小范围为: 0 ~ 2 …
存储协议栈
参考: http://brasstacksblog.typepad.com/brass-tacks/ http …