interleave two text files with specified lines
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的更多相关文章
- 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: ...
- 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 ...
- 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 ...
- text files and binary files
https://en.wikipedia.org/wiki/Text_file https://zh.wikipedia.org/wiki/文本文件
- 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 ...
- Counting Lines, Words, and Characters with wc
Counting Lines, Words, and Characters with wc When working with text files, you sometimes get a ...
- Using Option Files
Most MySQL programs can read startup option files(sometimes called configuration files). Option file ...
- 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 ...
- 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 ...
随机推荐
- C#关于日期 月 天数 和一年有多少周及根据某年某周获取时间段的计算(转)
/// 当前月有多少天 /// </summary> /// <param name="y"></param> /// <param na ...
- Markdown  --> <img ... />
search \!\[(\w+)\]\(([a-zA-Z0-9/.]+)\) replace <img src="$2" width="30%"/>
- Java + selenium 元素定位(4)之By CSS
这篇我要介绍元素定位的倒数第二个方法啦,就是基于CSS的元素定位.关于一些CSS的知识,我这里就不累赘的讲了,以后可能会单独写一篇关于CSS的介绍.当然个人推荐如果之前完全没有CSS只是储备的,可以选 ...
- hdu3518 Boring counting(后缀数组)
Boring counting 题目传送门 解题思路 后缀数组.枚举每种长度,对于每个字符串,记录其最大起始位置和最小起始位置,比较是否重合. 代码如下 #include <bits/stdc+ ...
- 字符串模式匹配算法系列(一):BF算法
算法背景: BF(Brute Force)算法,是一种在字符串匹配的算法中,比较符合人类自然思维方式的方法,即对源字符串和目标字符串逐个字符地进行比较,直到在源字符串中找到完全与目标字符串匹配的子字符 ...
- centosifcfg-eth0文件内容为空
虚拟机安装好CentOS 6系统后,发现ip在每次重启后都会还原,用ifconfig查看是有eth0网卡的(也有可能只有回环网卡lo),于是查看eth0网卡配置文件,发现在 /etc/sysconfi ...
- 精简Docker镜像的几个方法
一.使用更精简的镜像 常用的Linux系统镜像一般有 Debian.Ubuntu.CentOS和Alpine,其中Alpine是面向安全的轻量级Linux发行版本.Docker的Alpine镜像仅有不 ...
- 洛谷 P1462 通往奥格瑞玛的道路——二分+spfa
上一波链接 https://www.luogu.org/problem/P1462 这道题我们考虑二分答案 然后每次跑一次spfa判断是否能够到达n点 tips:在不考虑负权边的前提下我们写最短路最好 ...
- SAP Smartforms打印输出条形码 及相关问题
最近凭证打印需要附加打印条形码,遂做了一个小例子,结果还出现了很多的小问题,按领导的话说,这就是经验! 首先:SE73 -> 系统条形码 -> 更改 -> 创建 -> 选择 N ...
- c# WInform 自定义导航布局
问题形成原因:软件一般都是左侧树导航或上部菜单导航,做好一个软件后,有的客户可能想用一个页面做导航图像,而各个客户用的功能可能不同,所以导航布局需要自定义. 思路:1.把菜单列出来 2.双击菜单生成一 ...