[Shell command] Remove the first N characters from every line

Created on November 28, 2026

You can use the -e option of the sed command to remove the first N characters from every line.

First, create a text file named dummy.txt.

one
two
three

Pass the contents of dummy.txt to sed. The expression "s/^.\{2\}//" replaces the first two characters with an empty string.

cat dummy.txt | sed -e "s/^.\{2\}//"

Output

e
o
ree
Shell command