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 ...
随机推荐
- 美化Windows
更改壁纸 https://www.omgubuntu.co.uk/2010/09/a-look-back-at-every-ubuntu-default-wallpaper google: ubunt ...
- 12. Jmeter-断言
jmeter-断言介绍与使用 性能测试中较少用到断言.断言会增加脚本执行时间,但是接口测试中断言是必备的.什么是断言?其实就是功能测试中常说的预期结果和实际结果是否相等. 响应断言 JSON Asse ...
- 2018 China Collegiate Programming Contest Final (CCPC-Final 2018)(A B G I L)
A:签到题,正常模拟即可. #include<bits/stdc++.h> using namespace std; ; struct node{ int id, time; }; nod ...
- QTP——改变Excel的单元格颜色
Public Function QTP_Change_Color(pathway,sheetname,x,y,color) Dim srcData,srcDoc,sp1,sp2,num, ...
- Java管理Cookie增删改查操作。
Cookie属性 了解这几个属性之后,就知道如何进行Cookie的操作了. name Cookie的名称. value Cookie的值. maxAge Cookie的失效时间,有以下几种值,默认为- ...
- Logback配置,error和普通日志分离
<?xml version="1.0" encoding="utf-8"?> <configuration> <springPro ...
- Linux系统实验
前言:怎么感觉Linux运维和Linux系统实验没什么关系?该不会的还是不会(@@).记录一下几个实验吧. 本篇目录: 实验一 编程环境 实验二 文件读写 实验三 进程通信 实验一 编程环境√ 实验步 ...
- css识别空格回车符
新闻发布系统文字需要换行,后台返回数据包含空格.回车符号需要默认显示出来.在父元素加上css样式 :white-space:pre:即可. 例:<div class="white-sp ...
- shell函数与变量
- 移动终端的GPU显卡介绍
嵌入式领域里面,不同的SOC芯片往往喜欢采用不同的GPU,目前为止有4家公司提供移动端的GPU芯片:ARM.Imagination Technologies.Vivante和Nvidia (高通Adr ...