linux下命令行的使用:使用sed命令操作文件

用该命令sed删除文件test.txt中包含某个字符串abc的行:

sed '/adc/d' test.txt >result.txt

在文件test.txt中删除从开头到含有某个字符串abc的行 

 sed '1,/abc/d' test.txt >result.txt

获取文件test.txt中包含字符串abc的行

cat test.txt |grep "abc" > result.txt

sed具体用法如下: 

用法: sed [选项]... {脚本(如果没有其他脚本)} [输入文件]...

-n, --quiet, --silent
取消自动打印模式空间
-e 脚本, --expression=脚本
添加“脚本”到程序的运行列表
-f 脚本文件, --file=脚本文件
添加“脚本文件”到程序的运行列表
--follow-symlinks
直接修改文件时跟随软链接
-i[扩展名], --in-place[=扩展名]
直接修改文件(如果指定扩展名就备份文件)
-l N, --line-length=N
指定“l”命令的换行期望长度
--posix
关闭所有 GNU 扩展
-r, --regexp-extended
在脚本中使用扩展正则表达式
-s, --separate
将输入文件视为各个独立的文件而不是一个长的连续输入
-u, --unbuffered
从输入文件读取最少的数据,更频繁的刷新输出
--help 打印帮助并退出
--version 输出版本信息并退出

如果没有 -e, --expression, -f 或 --file 选项,那么第一个非选项参数被视为
sed脚本。其他非选项参数被视为输入文件,如果没有输入文件,那么程序将从标准
输入读取数据。

GNU版sed主页: <http://www.gnu.org/software/sed/>。
使用GNU软件所需帮助文档: <http://www.gnu.org/gethelp/>。
将错误报告通过电子邮件发送到:<bug-gnu-utils@gnu.org>.
请务必将单词“sed”放在标题的某处。

 其他某些用法:http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html 

转载于:https://www.cnblogs.com/xiayexingkong/archive/2013/06/14/3135775.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/274206.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

ux的重要性_UX中清晰的重要性

ux的重要性重点 (Top highlight)Times, since the very first occurrences of web design in the 90’s, have changed a lot design-wise. The particular technology and its applications got more stable. Human-computer interaction (HCI) was deeply researched, design…

工欲善其事,必先利其器

vs2010中一些常用的快捷键、组合键&#xff1a; 1、快速格式化 CtrlED 2、注释选中部分 CtrlEC 3、停止调试 ShiftF5 4、取消注释选中部分 CtrlEU 5、显示解决方案资源管理器 CtrlWS 6、快速折叠 CtrlMO 7、封装一个字段 CtrlRE 8、查看属性 CtrlWP 9…

可靠消息最终一致性设计_如何最终启动您的设计产品组合

可靠消息最终一致性设计It’s not a secret that most designers procrastinate on their portfolios whether it is to update them or to create them in the first place.大多数设计师在更新产品组合时还是拖延产品组合并不是秘密。 首先创建它们 。 Hopefully, by the e…

台式机共享笔记本的无线网络(只需要一根网线)

以windowsXP系统为例 一、笔记本的设置方法&#xff1a; 1.先将笔记本的无线连接共享给有线网卡 将鼠标放到桌面的 网上邻居 上&#xff0c;按鼠标右键&#xff0c;选属性&#xff0c;再将鼠标放到无线连接上&#xff0c;又是按鼠标右键&#xff0c;选属性&#xff0c;在弹出的…

游戏用户体验指标_电子游戏如何超越游戏化的用户体验

游戏用户体验指标游戏UX (GAMES UX) During a time when the time spent on video games has reached record breaking heights, due to excessive time indoors, gamification has more of a place now than ever before.d uring的时候花在视频游戏的时间已经达到了 破纪录的高…

JAVA编程心得-JAVA实现CRC-CCITT(XMODEM)算法

CRC即循环冗余校验码&#xff08;Cyclic Redundancy Check&#xff09;&#xff1a;是数据通信领域中最常用的一种差错校验码&#xff0c;其特征是信息字段和校验字段的长度可以任意选定。 1 byte checksum CRC-16 CRC-16 (Modbus) CRC-16 (Sick) …

什么字体字母和数字大小一样_字母和字体如何适应我们的屏幕

什么字体字母和数字大小一样Writing went through many iterations before it became what is today. Times New Roman wasn’t the default script for ancient Egyptians, in fact, paper didn’t even exist when the first words were written.写作经历了许多迭代&#xff…

jenkins 通过批处理自动构建 非标准项目

之前介绍了java和vs2010的项目构建&#xff0c;这些都是比较常见的&#xff0c;所以都用专门的工具。但但难免会遇到一些不常见的项目&#xff0c;下面介绍通过批处理进行构建&#xff0c;并用jenkins调用.我们这里使用plc语言&#xff0c;没有标准环境&#xff0c;只有使用bat…

效果图底图 线框图_5分钟的线框图教程

效果图底图 线框图为什么使用线框&#xff1f; (Why wireframe?) Simply put, wireframes provide a structure and layout for content and assets.简而言之&#xff0c;线框提供了内容和资产的结构和布局。 You can wireframe just about any kind of presentation, from p…

多线程 - 你知道线程栈吗

问题 1. local 变量的压栈和出栈过程 void func1(){ int a 0; int b 0; } 系统中有一个栈顶指针&#xff0c;每次分配和回收local 变量时&#xff0c;其实就是移动栈指针。 2. static local变量的分配风险 void func2(){ static int a 0; } 这个变量a可能会被分…

怎么让qt发声_第3部分:添加网络字体-让我们的单词发声

怎么让qt发声This is a big week for the project. While it was an important step last week to establish some basic responsiveness, we couldn’t really nail down the typography until we added the typeface. Too many aspects of the feel, proportions, and overal…

mysql语句中把string类型字段转datetime类型

mysql语句中把string类型字段转datetime类型在mysql里面利用str_to_date&#xff08;&#xff09;把字符串转换为日期此处以表h_hotelcontext的Start_time和End_time字段为例&#xff0c;查询当前时间在此范围之内的数据。 www.2cto.com select * from h_hotelcontext where …

名词解释:对等知识互联网_网站设计理论:比较和对等

名词解释:对等知识互联网Equivalence and contrast, connection and distinction, categorization and non-categorization are all ways to distinguish the same or different elements. Based on the information they carry, we hope that the equivalent elements can hav…

hadoop深入研究:(五)——Archives

转载请注明来源地址&#xff1a;http://blog.csdn.net/lastsweetop/article/details/9123155 简介 我们在hadoop深入研究:(一)——hdfs介绍里已讲过&#xff0c;hdfs并不擅长存储小文件&#xff0c;因为每个文件最少一个block&#xff0c;每个block的元数据都会在namenode节点占…

人民币小写金额转大写金额

#region 人民币小写金额转大写金额/// <summary>/// 小写金额转大写金额/// </summary>/// <param name"Money">接收需要转换的小写金额</param>/// <returns>返回大写金额</returns>public static string ConvertMoney(Decimal…

饥饿的盛世读后感_满足任何设计师饥饿感的原型制作工具

饥饿的盛世读后感Tell me if this story sounds familiar to you. You just wrapped up a design in Sketch -a design that took you hours, and now you want to bring it to life. Sketch’s built-in prototyping tool doesn’t allow you to create all the interactions …

关于软件版本的说明

Trial&#xff1a;试用版&#xff0c;软件在功能或时间上有所限制&#xff0c;如果想解除限制&#xff0c;需要购买零售版。 Retail&#xff1a;零售版。Free&#xff1a;免费版。Full&#xff1a;完全版。Alpha&#xff1a;内部测试版&#xff0c;通常在Beta版发布之前推出。…

figma 安装插件_我制作Figma插件的经验

figma 安装插件Since Figma released the Figma Community (Beta), I’ve been working on Figma plugins in my free time while I study the code. With the help of an engineer friend of mine, I’ve developed four small plugins so far. As I continue to update these…

术语解释_术语

术语解释Colour has a great impact in the world around us and this is no different in User Interfaces (UI). However, it’s not always given the importance it deserves. Sometimes colour is understood as a purely aesthetic element that is completely relative …

安卓中的对话框通知---简单的对话框入门

当你的应用需要显示一个进度条或需要用户对信息进行确认时&#xff0c;可以使用对话框来完成。 1、用一个按钮来进行测试&#xff0c;在layout文件中的activity_main.xml文件中添加一个Button按钮&#xff1a; <RelativeLayout xmlns:android"http://schemas.android.c…