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 ...
随机推荐
- 《单词的减法》state1~state17(第一遍学习记录)
单词的减法 2016.05.18 state 1 accordingly 因此,相应地,对应地 advisory 顾问的,劝告的 annoy 打扰,干扰,使恼怒 anticipate/particip ...
- Html5 学习笔记 【PC固定布局】 实战4 footer 区域
最终效果图: Html代码: <!DOCTYPE html> <html lang="zh-cn"> <head> <meta chars ...
- mybatis分页插件使用
一:导入依赖 <!--分页插件--> <dependency> <groupId>com.github.pagehelper</groupId> < ...
- B. pSort
题目链接: http://codeforces.com/problemset/problem/28/B 题意: 给一个n,原本有个1到n按顺序排列的序列,给一个序列问,在给一个数组,表示这个位置的数可 ...
- 修改默认runlevel
CentOS直接修改文件 /etc/inittab 就好了 # Default runlevel. The runlevels used are: # - halt (Do NOT set init ...
- go读写excel文件
首先,需要安装golang用来操作excel文档的类库: go get github.com/Luxurioust/excelize 一.excel文件创建与写入 package main impor ...
- android ListView列表显示数据
item.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:and ...
- 【学习总结】Python-3-风格各异的数值类型实例
菜鸟教程-Python3-基本数据类型 可能是考点的各种形态的数值类型 int型:正数负数,八进制0开头,十六进制0x开头 float型:小数点的前后都可以没有数字,自动补全 complex型:虚部的 ...
- js确认末尾字符算法挑战
检查一个字符串(str)是否以指定的字符串(target)结尾. 如果是,返回true;如果不是,返回false. 这个挑战可以通过在ES2015中引入的.endsWith()方法来解决.但是出于这个 ...
- elasticsearch 分析器 分词器
参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-tokenizers.html 在全文搜索(Fu ...