mixaill
mixaill

Reputation: 57

What means bash ${id:0:1} expression

What means bash ${id:0:1} expression?

Example of use:

wget -qc http://$host/image_${id:0:1}/$id/image.png -O ../../../folder

$id = number (1-8 digits)

Upvotes: 0

Views: 1511

Answers (1)

Mark Reed
Mark Reed

Reputation: 95315

It's a substring starting at index 0 (first character) and having length 1. So, it's the first character of the value of $id; if, for example, $id were 54321, then ${id:0:1} would be 5.

See all the available special parameter expansions in the manual.

Upvotes: 3

Related Questions