How to remove first n digits in bash with string substitution

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2024-04-13

How do you remove the first N characters of a string in bash?

e.g. the 9_ prefixes here:


The trick is to put the string in a variable then use the following construct:


To do this in a loop, you might have something like this:

for file in *.jpg; do echo "${file:2}"; done