问题描述
我必须删除大文件中第n个字符. Vi
会挂起这么大的文件.我知道 sed
中会有一些简单的命令可以做到这一点.但是,我发现很难理解 sed
脚本及其表达式.
I have to delete a character at nth position in a big file. Vi
hangs for such a big file. I know there will be some simple command in sed
to do so. But, I find it difficult to understand sed
scripts and its expressions.
我拥有的文件内容如下:
The file I have has content like:
我必须删除多余的
,即该文件中第 130405
个字符.我如何使用sed实现这一目标.
I have to delete that extra ,
which is 130405
th character in that file. How do I use sed to achieve this.
现在,我希望将所有双逗号替换为一个.该怎么办?
Now I wish to replace all aoocurances of double comma by a single one in-place. How can that be done?
推荐答案
sed -i's/.//130405'FILE
这将在位置( -i
)上编辑文件( FILE
),删除位置 130405处的任何字符(
.
).
This edits the file (FILE
) in place (-i
), deleting any character (.
) at position 130405
这篇关于如何使用sed删除文件中的第n个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!