python to shell vimdiff
目录
#!/bin/python3
import os
import sys
if(len(sys.argv) != 3):
exit ("Usage: argv1:fullPath.txt argv2:partPath.txt")
try:
fullpath = open(sys.argv[1])
partpath = open(sys.argv[2])
shell = open('vimdif.sh','w')
except(OSError):
print('open file failed! reason:'+ str(reason))
fullPathL = fullpath.readlines()
partPathL = partpath.readlines()
outlist = []
for path in partPathL:
for fpath in fullPathL:
if(fpath.find(path) != -1):
print(fpath,path)
outlist.append(fpath)
break
#write shell
iter=0
shell.writelines('#!/bin/bash\n')
shell.writelines('if [ $# -lt 1 ];then\n')
shell.writelines(' echo argv:compare file dir\n')
shell.writelines(' exit\n')
shell.writelines('fi\n')
for path in outlist:
shell.writelines('pathArr['+str(iter)+']='+path)
iter = iter + 1
shell.writelines('\nfor trueFilepath in ${pathArr[*]}\n')
shell.writelines('do\n')
shell.writelines(' arr=(${trueFilepath//// })\n')
shell.writelines(' len=${#arr[*]}\n')
shell.writelines(' compareFile=$1${arr[${len}-1]}\n')
shell.writelines(' echo ${trueFilepath}\n')
shell.writelines(' if test -r $trueFilepath -a -r $compareFile;then\n')
shell.writelines(' vim -d $trueFilepath $compareFile\n')
shell.writelines(' fi\n')
shell.writelines('done\n')
python to shell vimdiff的更多相关文章
- python 调用 shell 命令方法
python调用shell命令方法 1.os.system(cmd) 缺点:不能获取返回值 2.os.popen(cmd) 要得到命令的输出内容,只需再调用下read()或readlines()等 ...
- 【转】为eclipse安装python、shell开发环境和SVN插件
原文网址:http://www.crazyant.net/1185.html eclipse是一个非常好用的IDE,通常来说我们都用eclipse来开发JAVA程序,为了让开发python.shell ...
- python执行shell获取硬件参数写入mysql
最近要获取服务器各种参数,包括cpu.内存.磁盘.型号等信息.试用了Hyperic HQ.Nagios和Snmp,它们功能都挺强大的,但是于需求不是太符,亦或者太heavy. 于是乎想到用python ...
- python调用shell, shell 引用python
python 调用 shell get_line_num="wc -l as_uniq_info | awk '{print $1}'" ###get the lines of & ...
- python 调用shell命令三种方法
#!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器: #!/usr/bin/env python这种用法是为了防止操作系统用户没有将pyth ...
- python编写shell脚本详细讲解
python编写shell脚本详细讲解 那,python可以做shell脚本吗? 首先介绍一个函数: os.system(command) 这个函数可以调用shell运行命令行command并且返回它 ...
- python 调用 shell 命令
记录 python 调用 shell 命令的方法 加载 os 模块, 使用 os 类 import os; os.system("ls /");
- 为eclipse安装python、shell开发环境和SVN插件
http://www.crazyant.net/1185.html 为eclipse安装python.shell开发环境和SVN插件 2013/08/27 by Crazyant 暂无评论 eclip ...
- Python 调用 Shell脚本的方法
Python 调用 Shell脚本的方法 1.os模块的popen方法 通过 os.popen() 返回的是 file read 的对象,对其进行读取 read() 的操作可以看到执行的输出. > ...
随机推荐
- workqueue --最清晰的讲解【转】
转自:https://www.cnblogs.com/zxc2man/p/6604290.html 带你入门: 1.INIT_WORK(struct work_struct *work, void ( ...
- 通过fiddler和逍遥模拟器模拟抓包android手机
环境说明 Fiddler/逍遥手机模拟器 安装在10.11.0.148的电脑中 逍遥模拟器会自动生成wifi连接到 10.11.0.148上网 开启https: 在模拟器中打开 http://代理:8 ...
- 【原创】大数据基础之Kafka(1)简介、安装及使用
kafka2.0 http://kafka.apache.org 一 简介 Kafka® is used for building real-time data pipelines and strea ...
- Python--map()函数
map()是 Python 内置的高阶函数,它接收一个函数 f 和一个 list,并通过把函数 f 依次作用在 list 的每个元素上,得到一个新的 list 并返回. 例如,对于list [1, 2 ...
- chromerdriver下载地址:xpath_help
chrome下载地址 http://npm.taobao.org/mirrors/chromedriver xpath_help https://blog.csdn.net/Cayny/article ...
- Mac osx 系统安装 eclipse
https://jingyan.baidu.com/article/fea4511ad46a86f7bb9125e5.html
- scrapy 通过FormRequest模拟登录再继续
1.参考 https://doc.scrapy.org/en/latest/topics/spiders.html#scrapy.spiders.Spider.start_requests 自动提交 ...
- sklearn交叉验证2-【老鱼学sklearn】
过拟合 过拟合相当于一个人只会读书,却不知如何利用知识进行变通. 相当于他把考试题目背得滚瓜烂熟,但一旦环境稍微有些变化,就死得很惨. 从图形上看,类似下图的最右图: 从数学公式上来看,这个曲线应该是 ...
- C++运算符重载——类型转换
类型转换函数能够实现把一个类 类型 转换成 基本数据类型(int.float.double.char等) 或者 另一个类 类型. 其定义形式如下,注意不能有返回值,不能有参数,只能返回要转换的数据类型 ...
- sql server 中getdate() 的日期时间字符串表示法
1. SELECT CONVERT(varchar(100), GETDATE(), 0) 05 9 2011 9:12AM SELECT CONVERT(varchar(100), GETDATE( ...