a_file=$1
a_step=$2
b_file=$3
b_step=$4 a_start=1
let a_end=$a_start+$a_step b_start=1
let b_end=$b_start+$b_step a_lines=$(wc -l $a_file | awk '{print $1}')
b_lines=$(wc -l $b_file | awk '{print $1}') while true
do
awk "NR >= $a_start && NR < $a_end {print}" $a_file
awk "NR >= $b_start && NR < $b_end {print}" $b_file
let a_start=$a_start+$a_step
let a_end=$a_end+$a_step
let b_start=$b_start+$b_step
let b_end=$b_end+$b_step if [ $a_start -ge $a_lines ] && [ $b_start -ge $b_lines ]
then
break
fi #echo "a_start:" $a_start "a_end:" $a_end "b_start:" $b_start "b_end:" $b_end
#echo "a_file:" $a_file "a_step:" $a_step
#echo "b_file:" $b_file "b_step:" $b_step
done

  

Usage:

bash interleave.sh file_a 7 file_b 1

  

interleave two text files with specified lines的更多相关文章

  1. Writing Text Files On The Client in Oracle Forms 10g

    Below is the example to write file on client in Oracle Forms 10g with webutil library package.Note:  ...

  2. Access text files using SQL statements by DB Query Analyzer

    Access text files using SQL statements by DB Query Analyzer Ma Gen feng (Guangdong Unitoll Services ...

  3. How to read very large text files fast

    Question Does anyone know the fastest way to read large text files (10Mb) into a string.Readln is ju ...

  4. text files and binary files

    https://en.wikipedia.org/wiki/Text_file https://zh.wikipedia.org/wiki/文本文件

  5. Convert between Unix and Windows text files - IU Knowledge Base from: https://kb.iu.edu/d/acux

    vi. To input the ^M character, press Ctrl-v , and then press Enter or return . In vim, use :set ff=u ...

  6. Counting Lines, Words, and Characters with wc

      Counting Lines, Words, and Characters with wc   When working with text files, you sometimes get a ...

  7. Using Option Files

    Most MySQL programs can read startup option files(sometimes called configuration files). Option file ...

  8. How To Use the AWK language to Manipulate Text in Linux

    https://www.digitalocean.com/community/tutorials/how-to-use-the-awk-language-to-manipulate-text-in-l ...

  9. Under ubuntu 12.04,install sublime text 2

    Sublime Text is an awesome text editor. If you’ve never heard of it, you should check it out right n ...

随机推荐

  1. Centos 7.3 配置Xmanager XDMCP

    我们通常需要远程桌面,这会带来很好的便利性,而Centos7的XDMCP配置过程发生了变化,添加了很多新特性,初期难免会不适应,但新系统终究还是不错的.下面看看Centos7下如何配置XManager ...

  2. Python笔记(六)_函数

    函数一般是从第一行代码开始执行,结束于return语句.异常.或者函数所有语句执行完毕.一旦函数将控制权交还给调用者,就意味着全部结束.函数中做的所有工作以及保存在局部变量中的数据都将丢失.再次调用这 ...

  3. 2019.7.26 NOIP 模拟赛

    这次模拟赛真的,,卡常赛. The solution of T1: std是打表,,考场上sb想自己改进匈牙利然后wei了(好像匈牙利是错的. 大力剪枝搜索.代码不放了. 这是什么神仙D1T1,爆蛋T ...

  4. vue-router 传递参数的几种方式

    本文转载自:https://blog.csdn.net/crazywoniu/article/details/80942642 vue-router传递参数分为两大类 编程式的导航 router.pu ...

  5. css浮动以及清除

    首先要知道,div是块级元素,在页面中独占一行,自上而下排列,也就是传说中的流.如下图: 可以看出,即使div1的宽度很小,页面中一行可以容下div1和div2,div2也不会排在div1后边,因为d ...

  6. matploylib之热力图

    刚学我也不熟,做个笔记吧 # coding:utf-8 import numpy as np import matplotlib.pyplot as plt dx = 0.01 dy = 0.01 # ...

  7. 45.Sort List(链表排序)

    Level:   Medium 题目描述: Sort a linked list in O(n log n) time using constant space complexity. Example ...

  8. kubernetes里面有时候centos源用不了

    kubernetes里面有时候centos源用不了,快速配一个阿里云的源. mkdir /etc/yum.repos.d/yangback;mv /etc/yum.repos.d/* /etc/yum ...

  9. SQL数据库—<1>SQL语言

    关系数据库.SQL语言简单.学习软件介绍 SQL:Structured Query Language 结构化查询语言 数据库分为:层次型,网状型,关系型. 关系型数据库:是一个二维表的集合,可以用来存 ...

  10. getCss函数

    var box=document.getElementById('box'); function getCss(curEle,attr){ var val=null; //去单位 var reg=/^ ...