庆典 - 从文本文件中删除文本的多个不同线路 [英] bash - remove multiple different lines of text from a text file

查看:175
本文介绍了庆典 - 从文本文件中删除文本的多个不同线路的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的日志文件的工作,大部分日志文件有大量重复所记录的多次串。
为了使日志,易于观看的其他人谁没有太多这样的事情做(我自己也),我一直想拍一个脚本,剥去一些文本行,可能会导致一个假警报给其他人。 (嘿管理员,我这里有这些错误多次>唉,这些错误并不意味着什么的一种方式)

有没有使用grep,猫或AWK一些的bash code,可以摆脱许多不同文本行,而不必一遍又一遍地去通过文档的每一行被删除? (基本上去掉一举所有的垃圾行)

例如,我将标志着我在想删除的行粗体


  

有一件事我不知道为什么。


  
  

它甚至不不管你怎么努力


  
  

请记住这一点,我设计了这个
  韵


  
  

要在适当的时间解释


  
  

我只知道


  
  

时间是一件有价值的事情


  
  

看着它飞过的钟摆


  
  

看着它倒计时的结束
  日


  
  

时钟滴答的生活了


  
  

它是如此的不真实


  
  

没看出来以下


  
  

观看时向右走窗外


  
  

试图坚持,但根本不知道


  
  

浪费的这一切只是为了


  
  

看着你离去


很抱歉的林肯公园歌词,听收音机,一边试图解决一个问题给出了一些不好的例子有时:P

是否所有这些线路可移动的一个命令?
如果有人知道如何感谢。


解决方案

 的grep -v<字符串1> \\ |<字符串2> \\ |< stringN>中/路径/到/文件

I'm working with lots of log files, and most log files have lots of repeating strings that are logged multiple times. To make the logs easily viewable for others who don't have much to do with such things (for myself also), i've wanted to make a script that rips out some text lines that can cause a 'false alarm' to other people. ("Hey admin, i have these errors here multiple times"; > "Sigh, these errors don't mean anything" kind of way)

Is there some bash code with grep, cat or awk that can get rid of lots of different text lines, without having to go through the document over and over again for each line to be removed? (basically remove all garbage lines in one swoop)

Example, i'll mark the lines that i want removed in bold:

One thing I don't know why

It doesn’t even matter how hard you try

Keep that in mind, I designed this rhyme

To explain in due time

All I know

time is a valuable thing

Watch it fly by as the pendulum swings

Watch it count down to the end of the day

The clock ticks life away

It’s so unreal

Didn’t look out below

Watch the time go right out the window

Trying to hold on but didn’t even know

Wasted it all just to

Watch you go

Sorry about the Linkin Park Lyrics, listening to the Radio while trying to solve a problem gives some bad examples sometimes :P

Are all these lines removable in one command? Many thanks if somebody knows how.

解决方案

grep -v "<string1>\|<string2>\|<stringN>" /path/to/file

这篇关于庆典 - 从文本文件中删除文本的多个不同线路的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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