Shell/Python

bash 和 python 脚本分类
9 年前

sed 和 awk 示例操作对比

转载   sed和awk对比   Shell/Python  

   sed 和 awk 都是 Linux下常用的流编辑器,他们各有各的特色,本文并不是要做什么对比,而是权当好玩,把《SED单行脚本快速参考》这文章,用 awk 做了一遍~至于孰好孰坏,那真是很难评论了。一般来说,sed的命令会更短小一些,同时也更难读懂;而 awk 稍微长点,但是 if、while这样的,逻辑性比较强,更加像“程序”。到底喜欢用哪个,就让各位看官自…

9 年前

Shell脚本 SVN导出两个版本差异文件

Shell/Python   svn差异版本  

#!/bin/bash #导出指定版本之间的差异文件 如100到200之间的差异则导出100(不包括)-200(包括)的所有修改 SVN_URL="svn://192.168.1.23/svn/repotest" if [ -z $2 ] && [ $1 -gt $2 ] ; then echo "You must useage like $0 old_vers…

9 年前

python 脚本交互输入系统命令时实现Tab补全

Shell/Python   raw_input tab 补全  

command_tab.py #/usr/bin/python #coding:utf8 import readline,os,commands,sys readline.set_completer_delims(' \t\n`~!@#$%^&*()=+[{]}\\|;:\'",<>/?') def allcommands(): a=commands.get…

9 年前

python 对ini配置文件的读写操作

Shell/Python   configparser  

ini 文件格式 ini 一般为文本文件,数据格式例 [hk] node_ip = 2.2.2.2 [cn] node_ip2 = 4.4.4.4 node_ip = 1.1.1.1 [us] node_ip = 3.3.3.3 ini 文件可以分为几个 Section,每个 Section 的名称用 [] 括起来,在一个 Section 中,可以有很多的 Key,每一个 Key 可以有一…

9 年前

MySQL 备份脚本

Shell/Python  

#!/bin/bash dstpath=/data/backup/db today=`date +%Y%m%d` backpath=$dstpath/$today # 备份目录格式 /data/backup/db/20150609 dbhost=127.0.0.1 # 数据库地址 dbuser=…