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() 的操作可以看到执行的输出. > ...
随机推荐
- centos7中nfs文件系统的使用
需求: file01:1.1.1.1(内网ip 172.20.103.212),file02:2.2.2.2(内网ip 172.20.103.211) 这两台机器的 /dev/mapper/myvg- ...
- NYOJ
爬行的蚂蚁 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 有N只蚂蚁以每秒1cm的速度在长为Lcm的竿子上爬行.当蚂蚁爬到竿子的端点时就会掉落.由于竿子太细,两只蚂 ...
- activiti 涉及的内容
1 JAVA 委派模式(Delegate) https://blog.csdn.net/mayaofr/article/details/52082665 2 Activiti中的activiti:ex ...
- Python-Django-BMS-增删改查
无名分组 有名分组 反向解析 更改路由后不影响,动态传值 locals()传参 queryset.update() 自定义过滤器 {{forloop.counter}} new.authors.add ...
- H - 栀子花开
这是一个栀子花开的季节,也是一个离别的季节,四年一千多个日日夜夜,那校园的角角落落,留下了我们沉思的身影:那上百次的成绩排名表,印证了我们深深浅浅不断进步的轨迹,但是这些进步都离不开老师的谆谆教诲. ...
- Codeforces 1109D Sasha and Interesting Fact from Graph Theory (看题解) 组合数学
Sasha and Interesting Fact from Graph Theory n 个 点形成 m 个有标号森林的方案数为 F(n, m) = m * n ^ {n - 1 - m} 然后就 ...
- spark MLlib collaborativeFilltering学习
package ML.collaborativeFilltering; import org.apache.spark.SparkConf; import org.apache.spark.api.j ...
- P2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm 记忆化搜索dfs
题目描述 每年,在威斯康星州,奶牛们都会穿上衣服,收集农夫约翰在N(1<=N<=100,000)个牛棚隔间中留下的糖果,以此来庆祝美国秋天的万圣节. 由于牛棚不太大,FJ通过指定奶牛必须遵 ...
- IMCASH:看着朋友赚钱进币圈 我凭啥亏钱? 4月29日币圈报告
即将过去的四月份,币圈的行情总体是不错的,比特从4000附近最高涨到了5600以上的位置,当前也在5200左右,而成交量更是创出历史天量(4月3日,全球加密货币市场的交易量达890亿美元,创历史天量) ...
- Gym 100963B
Gym 100963B啊,郁闷,就tm调小了一点范围就A了,就写dp和贪心比较一下,范围到最大值的二倍-1就好了假设最大值的2倍以内能满足最优条件,当金额范围超过最大值2倍的时候:至于为什么,还不清楚 ...