Home » Linux » delete the first 5 chars on any line of a textfile in Linux with sed

delete the first 5 chars on any line of a textfile in Linux with sed

Posted by: admin November 30, 2017 Leave a comment

Questions:

i need a 1liner to remove the first 5 chars on any line of a text file, but i dont know sed, could anyone help me please?

Answers:
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.

Questions:
Answers:

Use cut:

cut -c6-

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

Questions:
Answers:
sed 's/^.\{,5\}//' file.dat

Questions:
Answers:
awk '{print substr($0,6)}' file