Linux/shell: remove adjacent similar patterns
cat > temp004
AA1
a
b
c
AA2
AA3
a
b
c
AA4
a
b
c
AA5
AA6
awk '
BEGIN {pre=0; str="";}
{ if(NR==1){
if($0 ~ /AA/)
{pre=1;}
else {pre=0;}
str=$0;
}
else {
if($0 ~ /AA/)
{curr=1; }
else {curr=0;}
if( curr == 1 && pre == 1)
{ ;}
else
{ print str; }
str=$0;
pre=curr;
}
} END{ print str;}' temp004
AA1
a
b
c
AA3
a
b
c
AA4
a
b
c
AA6
Linux/shell: remove adjacent similar patterns的更多相关文章
- linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例 --转载
http://www.cnblogs.com/chengmo/archive/2010/10/14/1851434.html nux shell有一套自己的流程控制语句,其中包括条件语句(if),循环 ...
- linux shell 流程控制
导读 和Java.PHP等语言不一样,linux shell有一套自己的流程控制语句,其中包括条件语句(if),循环语句(for,while),选择语句(case).下面我将通过例子介绍下,各个语句使 ...
- Bash For Loop Examples for Your Linux Shell Scripting--ref
There are two types of bash for loops available. One using the “in” keyword with list of values, ano ...
- 学习笔记之Linux / Shell / QSHELL
shell(计算机壳层)_百度百科 http://baike.baidu.com/subview/849/15831672.htm Shell (computing) - Wikipedia, the ...
- Linux shell下30个有趣的命令
Tips 原文作者:Víctor López Ferrando 原文地址:30 interesting commands for the Linux shell 这些是我收集了多年的Linux she ...
- run commands in linux shell using batch file
adb shell as root after device rooted once device rooted, we must perform "su" before we g ...
- [转]linux shell 流程控制(条件if,循环【for,while】,选择【case】语句实例
原文链接:http://www.cnblogs.com/chengmo/archive/2010/10/14/1851434.html linux shell有一套自己的流程控制语句,其中包括条件语句 ...
- Linux-(3)Linux Shell 使用
三.Linux Shell 3.1 文件管理 3.1.1 ls 命令 显示指定工作目录下的内容及属性信息 ls 命令是Linux下最常用的指令之一.ls命令为英文单词 list 的缩写,正如英文单词 ...
- Linux shell脚本基础学习详细介绍(完整版)二
详细介绍Linux shell脚本基础学习(五) Linux shell脚本基础前面我们在介绍Linux shell脚本的控制流程时,还有一部分内容没讲就是有关here document的内容这里继续 ...
随机推荐
- 学习笔记<3>View接触
一.View基本概念 1.界面上显示所有的控件都是用对象表示的,即有类,这些类都是View的子类. 2.View的种类 二.在Activity当中获取代表View的对象 1.根据ID可以用方法获取到对 ...
- 17. Letter Combinations of a Phone Number(bfs)
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that th ...
- cookie中存取中文
- RobotFrameWork(一)robotfamework(python版)及Ride在windows安装
1.windows下的安装 (1)准备条件: python-2.7.3.msi robotframework-2.7.5.win32.exe wxPython2.8-win32-unicode-2.8 ...
- Java基础(basis)-----代码块详解
1.静态代码块 格式: static{ 内容..... } 随着类的加载而加载,而且只被加载一次 多个静态代码块之间按照顺序结构执行 优先其他各种代码块以及构造函数先执行 静态的代码块中只能执行静态的 ...
- GDB && QString
[1]GDB && QString GDB的print命令仅能打印基本数据类型,而像QString这样的复杂类型就无能为力了! 如果调试时不能看QString的值,很让人抓狂!!!幸好 ...
- c++学习笔记(八)- map
map<key, value>是按key排好序的,key不可以重复. 1. map.lower_bound():按key查找,如果查找的key存在,返回该位置,如果不存在返回大于所查找值的 ...
- linux常用命令:mkdir 命令
linux mkdir 命令用来创建指定的名称的目录,要求创建目录的用户在当前目录中具有写权限,并且指定的目录名不能是当前目录中已有的目录. 1.命令格式: mkdir [选项] 目录... 2.命令 ...
- Set接口——HashSet集合
不重复,无索引,不能重复元素,没有索引: HashSet集合: 此时实现Set接口,有哈希表(HashMap的一个实例)支持,哈希表意味着查询速度很快, 是无序的,即元素的存取的顺序可能不一致: 且此 ...
- web前端利用leaflet生成粒子风场,类似windy
wind.js如下: $(function() { var dixing = L.tileLayer.chinaProvider('Google.Satellite.Map', { maxZoom: ...