
代码片段
schrht
这个作者很懒,什么都没留下…
展开
-
[代码片段] shell(bash)文件锁
说明“代码片段”系列文章并非对相关知识的总结,而是为代码编写提供快速上手的模板,即通过复制粘贴代码再经过简单的修改以快速完成预期功能。代码片段# Locklockfile=$logdir/generate_pbench_fio_plots.lockif [ ! -e $lockfile ]; then echo $$ >$lockfile || exit 1 echo "$(basename $0): INFO: Locked with: $lockfile" >&am原创 2021-01-14 13:59:51 · 692 阅读 · 1 评论 -
[代码片段] shell(bash)创建及输出表格
说明“代码片段”系列文章并非对相关知识的总结,而是为代码编写提供快速上手的模板,即通过复制粘贴代码再经过简单的修改以快速完成预期功能。代码片段flist=$(ls *_$series.[0-9]*.log)for file in $flist; do re=$release se=$(echo $file | sed 's/.*_\(\w*\).\([0-9]*\).log/\1/') no=$(echo $file | sed 's/.*_\(\w*\).\([0-9]*\).log/\2原创 2021-01-14 13:57:35 · 2049 阅读 · 0 评论 -
[代码片段] Shell(bash)利用Python计算几何平均数和标准差
脚本执行路径codepath = os.path.split(os.path.abspath(__file__))[0]常用的函数os.getcwd() :获取python解释器执行脚本时候的所在地方file :当前文件路径os.path.dirname(file) : 某个文件所在的目录路径os.path.join(a, b, c) : 路径构造拼接 a/b/cos.path.abspath(path) : 将path从相对路径转成绝对路径os.pardir :上一层目录 Linu原创 2021-01-14 11:54:46 · 1092 阅读 · 0 评论 -
[代码片段]Python命令行参数(argparse)
代码片段1import argparseLOG = logging.getLogger(__name__)logging.basicConfig(level=logging.DEBUG, format='%(levelname)s:%(message)s')ARG_PARSER = argparse.ArgumentParser(description="Generate benchmark CSV")ARG_PARSER.add_argument( '--test_dir',原创 2020-11-30 12:17:27 · 355 阅读 · 0 评论 -
[代码片段] shell(bash)脚本参数解析(getopts)
说明“代码片段”系列文章并非对相关知识的总结,而是为代码编写提供快速上手的模板,即通过复制粘贴代码再经过简单的修改以快速完成预期功能。代码片段function show_usage() { echo "Copy image to another region." echo "$(basename $0) [-h] <-r from-region> <-R to-region> \<-i from-image-id | -n from-image-name原创 2021-01-06 12:09:40 · 522 阅读 · 0 评论