![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码片段
schrht
这个作者很懒,什么都没留下…
展开
-
[代码片段] shell(bash)文件锁
说明 “代码片段”系列文章并非对相关知识的总结,而是为代码编写提供快速上手的模板,即通过复制粘贴代码再经过简单的修改以快速完成预期功能。 代码片段 # Lock lockfile=$logdir/generate_pbench_fio_plots.lock if [ ! -e $lockfile ]; then echo $$ >$lockfile || exit 1 echo "$(basename $0): INFO: Locked with: $lockfile" >&am原创 2021-01-14 13:59:51 · 605 阅读 · 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 · 1921 阅读 · 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/c os.path.abspath(path) : 将path从相对路径转成绝对路径 os.pardir :上一层目录 Linu原创 2021-01-14 11:54:46 · 971 阅读 · 0 评论 -
[代码片段]Python命令行参数(argparse)
代码片段1 import argparse LOG = 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 · 292 阅读 · 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 · 449 阅读 · 0 评论