在Linux中从多个文件中删除文本行 [英] Remove line of text from multiple files in Linux

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

问题描述

有没有简单的方法从命令行下的文本文件夹中删除同一行文本?

解决方案

pre> sed -i.bak'/行文本/ d'*


$ b b

如果您的sed版本允许 -i.bak 标志(编辑就位)。如果不是简单地把它放在bash循环中:

 用于$(ls * .txt)中的文件
do
sed'/行文本/ d'$ file> $ file.new_file.txt
done


Is there a simple way to remove the same line of text from a folder full of text documents at the command line?

解决方案

sed -i.bak '/line of text/d' * 

If your version of sed allows the -i.bak flag (edit in place). If not simply put it in a bash loop:

for file in $(ls *.txt)
do
    sed '/line of text/d' $file > $file.new_file.txt
done

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

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