随笔分类 - 代码修炼
有用的编码技巧
摘要:strace 用法: -f :除了跟踪当前进程外,还跟踪其子进程。 -o file :将输出信息写到文件file中,而不是显示到标准错误输出(stderr)。 -p pid :绑定到一个由pid对应的正在运行的进程。此参数常用来调试后台进程。 用处: 查看别的命令或进程都进行了哪些系统调用。比如当前web.py进程号为7393; 用strace -p 7393 -f 等下一个客户请求过来后就可以看到webserver都干 了些什么.CP 拷贝指定文件情景:一个文件夹有各种文件:sh,log,data,py。我们只想把脚背相关的文件拷贝出来备份。解决:cp --p...
阅读全文
摘要:字符串分割1 #!/bin/bash 2 pwd=$(dirname $0) && cd ${pwd} 3 4 echo ================ [ $(date "+%F %T") BEGIN ] ======================= 5 6 sms_list="18610489065,13581697175,18600276158,18600574510,18600883672" 8 content="fuck" 9 10 if [[ -n "${content}" ]];
阅读全文
摘要:dict设置默认值 “” A common use of dictionaries is to count occurrences by setting the value of d[key] to 1 on its first occurrence, then increment the value on each subsequent occurrence. This can be done several different ways, but the get() method is the most succinct: ”“” ...
阅读全文