How to extract last part of string in bash?

后端 未结 6 1532
谎友^
谎友^ 2020-12-28 12:39

I have this variable:

A="Some variable has value abc.123"

I need to extract this value i.e abc.123. Is this possible i

6条回答
  •  甜味超标
    2020-12-28 12:57

    Yes; this:

    A="Some variable has value abc.123"
    echo "${A##* }"
    

    will print this:

    abc.123

    (The ${parameter##word} notation is explained in §3.5.3 "Shell Parameter Expansion" of the Bash Reference Manual.)

提交回复
热议问题