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.

  • logging_strict@lemmy.ml
    link
    fedilink
    English
    arrow-up
    1
    ·
    4 days ago

    it’s a bash community as long as bash is the right tool for the job. For text manipulation, not so much. In Python can also do some really stupid things. Then will get advice. They’ll say, just don't do that

    Which is what i’m doing here.

    just don't do that