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. 【GDAL】GDAL栅格数据结构学习笔记(一): 关于Metadata

    在维护一段代码时看到前任程序员写的获取栅格数据的CellSize的功能,竟然在知道GDAL的情况下去调用AE的接口来解算,觉得费解. 原来的思路是使用AE的Raster对象读取出Raster的文件大小 ...

  2. Codeforces 500D New Year Santa Network(树 + 计数)

    D. New Year Santa Network time limit per test 2 seconds memory limit per test 256 megabytes input st ...

  3. vue - blog开发学习4

    1.新建页面的修改,集成富文本编辑 edit-post.vue(新建和修改都用该组件) <template> <div class="editor"> &l ...

  4. WPF多线程更新UI的一个解决途径

    那么该如何解决这一问题呢?通常的做法是把耗时的函数放在线程池执行,然后切回主线程更新UI显示.前面的updateTime函数改写如下: private async void updateTime()  ...

  5. getopts的注意事项

  6. C++ I/O库练习

    编写函数,以读模式打开一个文件,将其内容读入到一个string的vector中,将每一行作为一个独立的元素存于vector中,并输出. 思路:1.以读的模式打开文件“目录.txt”: 2.先创建str ...

  7. windows系统下MySQL中遇到1045问题

    报错内容为"1045    Access denied for user 'root'@'localhost' (using password:YES)",对应的原因是密码错误,如 ...

  8. vscode 常用的插件

    这些是本人在使用vscode中用的比较爽的插件,个人爱好习惯不同,请按需拿取.先声明本人是一个前端,所用的,插件都是和前端匹配的,后台的同学可以不用浪费时间了 基础插件 chinese 英文是所有读书 ...

  9. ubuntu oracle数据库18c安装

    一.官网下载linux两个zip包 二.byqKx8a2tWcgBHb

  10. JavaScript设计模式小抄集(持续更新)

    前言 本文旨在记录JavaScript中常用的设计模式代码片段,简要说明使用场景,不过于追究细节.在设计模式开篇之前,还是先要搞清楚JavaScript中关于面向对象的基础知识,可以先看看JavaSc ...