Celeb Glow
updates | March 25, 2026

What does ":" (colon) operator in a bash variable expansion: VAR=${TEMP:3}?

What is the meaning of the following line in a variable in bash?

VAR=${TEMP:3}
6

3 Answers

This is variable expansion and works like this (notice this is only bash and ksh specific and will not work in a POSIX shell):

$ x=1234567890
$ echo ${x:3}
4567890
$ echo ${x:7}
890
$ echo ${x:3:5}
45678

  • ${var:pos} means that the variable var is expanded, starting from offset pos.
  • ${var:pos:len} means that the variable var is expanded, starting from offset pos with length len.
6

in bash it cuts away the first 3 characters of a (string) variable:

$ VAR="hello world"
$ echo ${VAR:3}
lo world

have a look at 'substring extraction' here: .

This operator cuts off the first 3 characters of variable TEMP and assigns the rest to variable VAR.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy