在shell脚本中的2个模式之间复制行数据 [英] copy lines data between 2 patterns in shell scripting

查看:192
本文介绍了在shell脚本中的2个模式之间复制行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的source.php文件如果模式匹配'<(单个小于)'>;我想要复制行号和行代码;(sinle quot大于逗号)





这是我希望输出的destination.php文件。





行号... 18,19,29不应该打印....因为它不符合B / T模式..所以如何删除这个....任何建议
$ b

解决方案

所有发生在'<和'';进入destination.php:

  sed -ne/'< /,/>'\; / wdestination。 phpsource.php 


This is my source.php file i want copy line number and line code if pattern matches between '<(single quot less than) and '>;(sinle quot greater than comma)

This is destination.php file i want output like this

line no... 18,19,29 should not print....becaus it not match B/T pattern..so how to remove this....any suggetion

解决方案

if you want to copy all lines that happens to be between '< and >'; into the destination.php :

sed -ne "/'</,/>'\;/wdestination.php" source.php

这篇关于在shell脚本中的2个模式之间复制行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆