MOHAMED
MOHAMED

Reputation: 43558

String usage with {} in bash

I have a kind of the following strings

str1="aaa.bbb."

and

str2="aaa.ccc"

I wan to call:

echo ${str1%.*}
echo ${str2%.*}

in order to get

"aaa.bbb." for str1

and "aaa." for str2

what should I use as expression inside {}

Upvotes: 1

Views: 53

Answers (1)

anubhava
anubhava

Reputation: 785761

Use it like this:

echo "${str1%.*}."
aaa.bbb.

echo "${str2%.*}."
aaa.

Upvotes: 1

Related Questions