用sed删除Linux中文本文件任意行的前五个字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3795512/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Delete the first five characters on any line of a text file in Linux with sed
提问by JBeg
I need a one-liner to remove the first five characters on any line of a text file. How can I do that with sed?
我需要一个单行来删除文本文件任何行上的前五个字符。我怎样才能用 sed 做到这一点?
采纳答案by Phil
sed 's/^.....//'
means
方法
replace ("s", substitute) beginning-of-line then 5 characters (".") with nothing.
替换 ("s", 替换) 行首然后 5 个字符 (".") 没有任何内容。
There are more compact or flexible ways to write this using sed or cut.
使用 sed 或 cut 有更紧凑或更灵活的方式来编写它。
回答by Ignacio Vazquez-Abrams
sed 's/^.\{,5\}//' file.dat
回答by Greg Hewgill
回答by ghostdog74
awk '{print substr(##代码##,6)}' file
回答by Gopi
sed 's/^.\{,5\}//' file.dat
worked like a charm for me
sed 's/^.\{,5\}//' file.dat
对我来说就像一种魅力