我在文件中有以下形式的数据:
<http://purl.uniprot.org/here> <http://purl.uniprot.org/here/unipot/purl>
<http://purl.uniprot.org/uniprot/Q196Y7> <http://purl.uniprot.org/core/annotation>
我想删除尖括号内的所有“http://purl.uniprot.org”。这样我得到的输出是
<here> <here/unipot/purl>
<uniprot/Q196Y7> <core/annotation>
我尝试使用 vi 的替换命令来做到这一点。但事实证明它很慢,因为我的文件是 1TB。有没有更有效的方法来使用 linux/python 做同样的事情
我知道我可以使用 sed 但 sed 找到模式并删除它们,而我想删除确切的内容
最佳答案
这应该在命令行下工作:
sed -i 's/http:\/\/purl.uniprot.org\///g' /path/to/filename
您可以先尝试不使用 -i
参数来查看控制台中的输出。
关于python - 从大文件中删除确切的字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19676953/