Question: I have many strings that look like the following:

```
word1.word2.word3.xyz
word1.word2.word3.word4.abc
word1.word2.mno
word1.word2.word3.pqr

```

Using bash, I would like to just get the string after the last '.'(dot) character.
So the output I want:

```
xyz
abc
mno
pqr

```

Is there any way to do this?

Answer: 
One simple solution would be to split the string on `.` and then get the last item from the splitted array

```bash
lines=(word1.word2.word3.xyz word1.word2.word3.xyz word1.word2.word3.word4.abc word1.word2.mno word1.word2.word3.pqr abcdef  'a * b')

for line in "${lines[@]}"
do
    line_split=(${line//./ })
    echo "${line_split[-1]}"
done

```

Another clean shell-checked way would be (the idea is the same)

```bash
lines=(word1.word2.word3.xyz word1.word2.word3.xyz word1.word2.word3.word4.abc word1.word2.mno word1.word2.word3.pqr abcdef)

for line in "${lines[@]}"; do
    if [[ $line == *.* ]]; then                 # check if line contains dot character
        IFS=. read -r -a split_array <<<"$line" # one-line solution
        echo "${split_array[-1]}"               # shows the results
    else
        echo "No dot in string: $line"
    fi
done

```
This is a one-liner solution (after array assignment), without using an explicit loop (but using `printf`'s implicit loop).

```
arr=( 'word1.word2.word3.xyz'
      'word1.word2.word3.word4.abc'
      'word1.word2.mno'
      'word1.word2.word3.pqr' )

printf '%s\n' "${arr[@]##*.}"

```