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的内容这里继续 ...
随机推荐
- html5-了解元素的属性
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8&qu ...
- Sitecore详细安装(包含sitecore安装过程截图)
一.到Sitecore 官网下载安装包 1)浏览器中输入https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform.aspx 2)安 ...
- kali长时间未使用导致数字签名过期无法更新源解决办法
kali长时间未使用,数字签名会过期,从而导致无法更新源. apt-get update:从源(Source)服务器那里下载最新的软件包列: apt-get upgrade:对已经安装的软件包本身进行 ...
- Presto上使用SQL遇到的一些坑
本文转载自:https://segmentfault.com/a/1190000013120454?utm_source=tag-newest 最近换了新工作,在数据处理方面,公司是用Presto连接 ...
- Twemproxy和Redis性能压力测试
性能测试 Redis自带了一个叫 redis-benchmark的工具来模拟N个客户端同时发出M个请求,(类似于Apache ab程序),你可以使用redis-benchmark -h来查看基准参数. ...
- Django模板系统 运算
记下来,省得每次google 过滤器,变量的显示形式的改变 一.形式:小写 {{ name | lower }} 二.串联:先转义文本到HTML,再转换每行到 <p> 标签 {{ my_t ...
- 关于scrapy下载文件重命名的办法以及对应url没有文件后缀的办法
https://www.jianshu.com/p/d1bb28cbb6a8 scrapy中负责下载文件的是class MyFilesPipeline(FilesPipeline)类 其中负责下载文件 ...
- Cannot assign “A1”: “B1” must be a “C1” instance.
应用 django FORM 录入数据 必须 item_id supplier_id 不能item, supplier
- phpstorm激活大全--持续更新(支持2018最新版)
方法一. 通过Licence Server 激活PHPStorm(快速) 方法原理是通过搭建服务器激活,不过网上有许多搭建好的. http://idea.goxz.gq http://v2mc.net ...
- Js扩容
/*脚本统一调用工具(企业端)*/ //杂项工具 var MiscUtils = { //去除字符串中所有的空格 ClearStringEmpty: function (str) { var strR ...