我的输入文件包含3000行。
system="This is nice"
system="Add some crazy word"
system="Some crazy word"
system="Add another pattern"
system="The parek went home"
system="Add Ola phradse"
system="The car is nice"
我想删除所有在系统="
后添加单词的行因此输入文件最终会像
一样system="This is nice"
system="Some crazy word"
system="The parek went home"
system="The car is nice"
答案 0 :(得分:1)
您可以在终端
中使用sed执行此操作<div class="slideshow-container">
<div class="mySlides fade">
<img src="http://i.dailymail.co.uk/i/pix/2017/03/01/14/3DD766C300000578-4271496-image-a-39_1488378897470.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<img src="https://hips.hearstapps.com/roa.h-cdn.co/assets/16/30/1469467513-01-2016-aston-martin-db9-gt.jpg" style="width:100%">
</div>
<div class="mySlides fade">
<img src="https://article.images.consumerreports.org/prod/content/dam/CRO%20Images%202017/Magazine-Articles/April/Google-Auto-Profile-images-2017/PRF-811" style="width:100%">
</div>
<div class="mySlides fade">
<img src="http://www.lexus.com/byl2014/pub-share/images/series/lc.png" style="width:100%">
</div>
</div>
<br>
<script>
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex> slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 2000); // Change image every 2 seconds
}
</script>
答案 1 :(得分:1)
如果有帮助,请您试试并告诉我。
解决方案1:在这里使用awk。
awk '!/system="Add/' Input_file
说明:搜索没有系统的行=“添加,如果是,则打印当前行。
解决方案第二:在这里使用grep。
grep -v '^system="Add' Input_file
说明:使用grep的-v
选项将省略匹配正则表达式的所有行,就像我从system="Add
开始给出一行,然后跳过它。