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() 的操作可以看到执行的输出. > ...
随机推荐
- DeepLearning.ai学习笔记(五)序列模型 -- week2 自然语言处理与词嵌入
一.词汇表征 首先回顾一下之前介绍的单词表示方法,即one hot表示法. 如下图示,"Man"这个单词可以用 \(O_{5391}\) 表示,其中O表示One_hot.其他单词同 ...
- DQL、DML、DDL、DCL区别
DQL(data query language)数据查询语言 主要是由SELECT构成的查询语句 基本语法:select 字段名 from 表名 where 查询条件 DML(data manipul ...
- mongoose 连接数据库操作
连接数据库 var mongoose = require('mongoose'); var schema = mongoose.Schema; // 连接MongoDB mongoose.connec ...
- MySql常见约束
含义:一种限制,用于限制表中的数据,为了保证表中数据的准确性和可靠性. 分类:六大约束 1.NOT NULL :非空,用于保证该字段的值不能为空.例如学生表的学生姓名及学号等等. 2.DEFAULT: ...
- Javascript模块化简史
Script标签和闭包 RequireJS, AngularJS以及依赖注入 Node.js以及CommonJS的出现 ES6, import, Babel和Webpack https://ponyf ...
- (原创)cocos lua 热更新从零开始(一)最简单demo
开发环境:WIN7 + cocos2dx 3.10 lua版本 0.学习这篇内容的基础是你要会创建并运行一个cocos lua项目 1.热更新的思想所谓的热更新,就是在线更新代码和资源.热更新的过程首 ...
- JAVA 数组元素的反转
package Code411;/*数组元素的反转本来[1,2,3,4]反转后[4,3,2,1]1.对称位置的元素交换2.对称位子需要两个索引3.int temp =a:a=b;b=temp;4.什么 ...
- 网络流24题——分配问题 luogu 4014
题目链接:这里 本题是一个典型的费用流问题,可以作为费用流建图模板使用 首先看到,每个人只能做一件工作,每件工作只能做一次,一个人做某件工作有一定的收益 那么我们建立一个超级源点st和超级终点ed,然 ...
- JS 判断传入的变量类型是否是Array
function f(arr){ 1.通过_proto_ 进行判断 (arr._proto_ 指向Array.prototype); 2.通过constructor进行判断 (arr.construc ...
- 分享一个学习的网站:每天会有大量AI相关的干货(论文分享,行业动态,相关竞赛经验分享等)http://www.deepsmart.ai/
网址:http://www.deepsmart.ai/ 微信公众号如下: