如何在文本文件中用行号替换特定的行? [英] How can I replace a specific line by line number in a text file?

查看:88
本文介绍了如何在文本文件中用行号替换特定的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Linux机器上有一个2GB的文本文件,我想将其导入数据库.

I have a 2GB text file on my linux box that I'm trying to import into my database.

我遇到的问题是,正在处理该rdf文件的脚本在一行上令人窒息:

The problem I'm having is that the script that is processing this rdf file is choking on one line:

mismatched tag at line 25462599, column 2, byte 1455502679:
<link r:resource="http://www.epuron.de/"/>
<link r:resource="http://www.oekoworld.com/"/>
</Topic>
=^

我想用</Line>替换</Topic>.我无法在所有行上进行搜索/替换,但是我有行号,因此我希望有一些简单的方法可以将一行替换为新文本.

I want to replace the </Topic> with </Line>. I can't do a search/replace on all lines but I do have the line number so I'm hoping theres some easy way to just replace that one line with the new text.

有什么想法/建议吗?

推荐答案

sed -i yourfile.xml -e '25462599s!</Topic>!</Line>!'

这篇关于如何在文本文件中用行号替换特定的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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