目录


#!/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. 论文笔记:Deep feature learning with relative distance comparison for person re-identification

    这篇论文是要解决 person re-identification 的问题.所谓 person re-identification,指的是在不同的场景下识别同一个人(如下图所示).这里的难点是,由于不 ...

  2. POJ 3347 Kadj Squares (计算几何)

    题目: Description In this problem, you are given a sequence S1, S2, ..., Sn of squares of different si ...

  3. vcenter新建虚拟机centos7作为虚拟机模板

    网卡选项 适配器类型算则E1000 Remote console选项 电源选项 加密 打开电源,连接iso安装系统 按一下tab键,修改网卡为eth0 点击Tab,打开kernel启动选项后,增加ne ...

  4. asp.net MVC路由配置总结

    URL构造 命名参数规范+匿名对象 routes.MapRoute(name: "Default",url: "{controller}/{action}/{id}&qu ...

  5. 【python】命令行神器 Click 简明笔记

    全文拷贝自 命令行神器 Click 简明笔记 Click Click 是用 Python 写的一个第三方模块,用于快速创建命令行.我们知道,Python 内置了一个 Argparse 的标准库用于创建 ...

  6. laravel 黑名单功能实现

    创建黑名单表迁移:php artisan make:model Models/BlackFeeds -m    (生成模型和迁移文件) 迁移文件中创建如下字段: public function up( ...

  7. jquery 第五章 jQuery操作表单与表格

    1.回顾 对象.bind("事件名称",function(){ // }) 阻止冒泡事件 return false,   event stopProapagation() 模拟事件 ...

  8. RxPermissions Usage

    refs:https://github.com/tbruyelle/RxPermissions https://www.jianshu.com/p/c3546e5cd2ffhttps://www.ji ...

  9. 数字滚动特效 NumScroll

    1.使用前先引入jquery2.前端学习群:814798690 下载地址 https://github.com/chaorenzeng/jquery.numscroll.js.git 快速使用 1.引 ...

  10. loj6077

    题解: 网上的做法好像都是容斥 那就先说一下容斥 首先问题等价于求下面这个式子的方案数 $$\sum_{i=1}^{n} ai (0<ai<i) =k$$ 直接$dp$复杂度是$nk$的, ...