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: 
AWK will do it. I'm using GNU AWK:

```
$ awk -F '.' '{print $NF}' <<EOF
word1.word2.word3.xyz
word1.word2.word3.word4.abc
word1.word2.mno
word1.word2.word3.pqr

EOF
xyz
abc
mno
pqr

```

AWK splits lines into fields and we use `-F` to set the field separator to `.`. Fields are indexed from 1, so `$1` would get the first one (e.g. `word1` in the first line) and we can use the variable `$NF` (for "number of fields") to get the value of the last field in each line.

<https://www.grymoire.com/Unix/Awk.html> is a great tutorial on AWK.

You can then just use a `for` loop to iterate over each of the resulting lines:

```
$ lines=$(awk -F '.' '{print $NF}' <<EOF
word1.word2.word3.xyz
word1.word2.word3.word4.abc
word1.word2.mno
word1.word2.word3.pqr

EOF
)
$ for line in $lines; do echo $line; done
xyz
abc
mno
pqr

```

I'm using command substitution here - see the [Advanced Bash Scripting Guide](https://tldp.org/LDP/abs/html/) for information on loops, command substitution and other useful things.
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[@]##*.}"

```