从文件中删除匹配词 [英] Remove match word from file

查看:69
本文介绍了从文件中删除匹配词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

File1.txt中的数据为

The Data in the File1.txt is

Raj cmd
Rahul cmd
Pooja cmd
Vilas cmd
Vikram cmd

我希望输出像下面这样打印

I want the Output to be Printed like this below

Raj
Rahul
Pooja
Vilas
Vikram

我要删除的单词是"cmd"

推荐答案

尝试一下:

sed 's/\s*cmd//' File1.txt 

说明

s/   # substitute
\s*  # ignore blanks
cmd  # your pattern
//   # replace with nothing

这篇关于从文件中删除匹配词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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