Skip Navigation

How does this code work?

I'm studying bash, and I came across this Stackoverflow thread which contains this bit of code:

var="abcde"
echo ${var%d*}

The output is abc, but I can't figure out why. I understand that %d is used to indicate an integer number and * represents anything, but I can't figure out why those together would truncate var to only 3 characters.

3

You're viewing a single thread.

3 comments