目录


#!/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的更多相关文章

  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. Selenium Navigation

    Navigating Navigate a link with WebDriver: driver.get("http://www.google.com") 1.Interacti ...

  2. noj算法 堡垒问题 回溯法

    描述: 城堡是一个4×4的方格,为了保卫城堡,现需要在某些格子里修建一些堡垒.城堡中的某些格子是墙,其余格子都是空格,堡垒只能建在空格里,每个堡垒都可以向上下左右四个方向射击,如果两个堡垒在同一行或同 ...

  3. 阿里云服务器Ubuntu 14.04.2和centos7.5实现nfs挂载

    前提条件,确保两个ip可以正常通信 确认服务端是否安装nfs-utils和rpcbind[root@localhost /]# rpm -qa|grep "nfs"nfs4-acl ...

  4. Windows Internals 笔记——内核对象

    1.每个内核对象都只是一个内存块,它由操作系统内核分配,并只能由操作系统内核访问.这个内存块是一个数据结构,其成员维护着与对象相关的信息. 2.调用一个会创建内核对象的函数后,函数会返回一个句柄,它标 ...

  5. Accumulation Degree

    #include<cstdio> #include<cstring> #define INF 0x7fffffff using namespace std; ; inline ...

  6. [DIV+CSS] set the screen capture Part 1 (div截取屏幕)

    使用下面的代码来获取屏幕.用DIV加CSS 来控制. 使用mousemove来获取移动的时候DIV的变化, 效果图如下: 使用5个DIV来组成实现截图目的第一部分,现在只是实现了选择的第一部分. HT ...

  7. Mongodb字段自增长

    MongoClient client = new MongoClient("mongodb://xxx.xxx.x.xx:27017"); var mongServer = cli ...

  8. Metaphor of topological basis and open set

    The definition of topological basis for a space $X$ requires that each point $x$ in $X$ is contained ...

  9. 关于input的检验问题

    写了很多小应用 但是 对于input有很多 相同的需求 在这里做一个总结 将用的多的校验方法 封装为方法 使用 1.只能输入正整数的校验 输入的时候同时校验 将字符类型的全部替换为空 <inpu ...

  10. SparkCore| 算子

    RDD RDD(Resilient Distributed Dataset)叫做弹性分布式数据集,是Spark中最基本的数据抽象.代码中是一个抽象类,它代表一个弹性的.不可变.可分区.里面的元素可并行 ...