Delete the first five characters on any line of a text file in Linux with sed

前端 未结 5 642
甜味超标
甜味超标 2020-12-13 01:35

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?

相关标签:
5条回答
  • 2020-12-13 01:59
    sed 's/^.....//'
    

    means

    replace ("s", substitute) beginning-of-line then 5 characters (".") with nothing.

    There are more compact or flexible ways to write this using sed or cut.

    0 讨论(0)
  • 2020-12-13 01:59
    awk '{print substr($0,6)}' file
    
    0 讨论(0)
  • 2020-12-13 02:07

    sed 's/^.\{,5\}//' file.dat worked like a charm for me

    0 讨论(0)
  • 2020-12-13 02:15
    sed 's/^.\{,5\}//' file.dat
    
    0 讨论(0)
  • 2020-12-13 02:16

    Use cut:

    cut -c6-
    

    This prints each line of the input starting at column 6 (the first column is 1).

    0 讨论(0)
提交回复
热议问题