目录

  1. #!/bin/python3
  2. import os
  3. import sys
  4. if(len(sys.argv) != 3):
  5. exit ("Usage: argv1:fullPath.txt argv2:partPath.txt")
  6. try:
  7. fullpath = open(sys.argv[1])
  8. partpath = open(sys.argv[2])
  9. shell = open('vimdif.sh','w')
  10. except(OSError):
  11. print('open file failed! reason:'+ str(reason))
  12. fullPathL = fullpath.readlines()
  13. partPathL = partpath.readlines()
  14. outlist = []
  15. for path in partPathL:
  16. for fpath in fullPathL:
  17. if(fpath.find(path) != -1):
  18. print(fpath,path)
  19. outlist.append(fpath)
  20. break
  21. #write shell
  22. iter=0
  23. shell.writelines('#!/bin/bash\n')
  24. shell.writelines('if [ $# -lt 1 ];then\n')
  25. shell.writelines(' echo argv:compare file dir\n')
  26. shell.writelines(' exit\n')
  27. shell.writelines('fi\n')
  28. for path in outlist:
  29. shell.writelines('pathArr['+str(iter)+']='+path)
  30. iter = iter + 1
  31. shell.writelines('\nfor trueFilepath in ${pathArr[*]}\n')
  32. shell.writelines('do\n')
  33. shell.writelines(' arr=(${trueFilepath//// })\n')
  34. shell.writelines(' len=${#arr[*]}\n')
  35. shell.writelines(' compareFile=$1${arr[${len}-1]}\n')
  36. shell.writelines(' echo ${trueFilepath}\n')
  37. shell.writelines(' if test -r $trueFilepath -a -r $compareFile;then\n')
  38. shell.writelines(' vim -d $trueFilepath $compareFile\n')
  39. shell.writelines(' fi\n')
  40. shell.writelines('done\n')

python to shell vimdiff的更多相关文章

  1. python 调用 shell 命令方法

    python调用shell命令方法 1.os.system(cmd) 缺点:不能获取返回值 2.os.popen(cmd) 要得到命令的输出内容,只需再调用下read()或readlines()等   ...

  2. 【转】为eclipse安装python、shell开发环境和SVN插件

    原文网址:http://www.crazyant.net/1185.html eclipse是一个非常好用的IDE,通常来说我们都用eclipse来开发JAVA程序,为了让开发python.shell ...

  3. python执行shell获取硬件参数写入mysql

    最近要获取服务器各种参数,包括cpu.内存.磁盘.型号等信息.试用了Hyperic HQ.Nagios和Snmp,它们功能都挺强大的,但是于需求不是太符,亦或者太heavy. 于是乎想到用python ...

  4. python调用shell, shell 引用python

    python 调用 shell get_line_num="wc -l as_uniq_info | awk '{print $1}'" ###get the lines of & ...

  5. python 调用shell命令三种方法

    #!/usr/bin/python是告诉操作系统执行这个脚本的时候,调用/usr/bin下的python解释器: #!/usr/bin/env python这种用法是为了防止操作系统用户没有将pyth ...

  6. python编写shell脚本详细讲解

    python编写shell脚本详细讲解 那,python可以做shell脚本吗? 首先介绍一个函数: os.system(command) 这个函数可以调用shell运行命令行command并且返回它 ...

  7. python 调用 shell 命令

    记录 python 调用 shell 命令的方法 加载 os 模块, 使用 os 类 import os; os.system("ls /");

  8. 为eclipse安装python、shell开发环境和SVN插件

    http://www.crazyant.net/1185.html 为eclipse安装python.shell开发环境和SVN插件 2013/08/27 by Crazyant 暂无评论 eclip ...

  9. Python 调用 Shell脚本的方法

    Python 调用 Shell脚本的方法 1.os模块的popen方法 通过 os.popen() 返回的是 file read 的对象,对其进行读取 read() 的操作可以看到执行的输出. > ...

随机推荐

  1. 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- ...

  2. NYOJ

    爬行的蚂蚁 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 有N只蚂蚁以每秒1cm的速度在长为Lcm的竿子上爬行.当蚂蚁爬到竿子的端点时就会掉落.由于竿子太细,两只蚂 ...

  3. activiti 涉及的内容

    1 JAVA 委派模式(Delegate) https://blog.csdn.net/mayaofr/article/details/52082665 2 Activiti中的activiti:ex ...

  4. Python-Django-BMS-增删改查

    无名分组 有名分组 反向解析 更改路由后不影响,动态传值 locals()传参 queryset.update() 自定义过滤器 {{forloop.counter}} new.authors.add ...

  5. H - 栀子花开

    这是一个栀子花开的季节,也是一个离别的季节,四年一千多个日日夜夜,那校园的角角落落,留下了我们沉思的身影:那上百次的成绩排名表,印证了我们深深浅浅不断进步的轨迹,但是这些进步都离不开老师的谆谆教诲. ...

  6. 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} 然后就 ...

  7. spark MLlib collaborativeFilltering学习

    package ML.collaborativeFilltering; import org.apache.spark.SparkConf; import org.apache.spark.api.j ...

  8. P2921 [USACO08DEC]在农场万圣节Trick or Treat on the Farm 记忆化搜索dfs

    题目描述 每年,在威斯康星州,奶牛们都会穿上衣服,收集农夫约翰在N(1<=N<=100,000)个牛棚隔间中留下的糖果,以此来庆祝美国秋天的万圣节. 由于牛棚不太大,FJ通过指定奶牛必须遵 ...

  9. IMCASH:看着朋友赚钱进币圈 我凭啥亏钱? 4月29日币圈报告

    即将过去的四月份,币圈的行情总体是不错的,比特从4000附近最高涨到了5600以上的位置,当前也在5200左右,而成交量更是创出历史天量(4月3日,全球加密货币市场的交易量达890亿美元,创历史天量) ...

  10. Gym 100963B

    Gym 100963B啊,郁闷,就tm调小了一点范围就A了,就写dp和贪心比较一下,范围到最大值的二倍-1就好了假设最大值的2倍以内能满足最优条件,当金额范围超过最大值2倍的时候:至于为什么,还不清楚 ...