cut string on last delimiter

 #For Filename
 echo "a.b.c.txt" | rev | cut -d"." -f2-  | rev
 #For extension
 echo "a.b.c.txt" | rev | cut -d"." -f1  | rev

There are many tools to do this.

As you were using cut :

$ string1="$(cut -d. -f1-3 <<<'a.b.c.txt')"
$ string2="$(cut -d. -f4 <<<'a.b.c.txt')"
$ echo "$string1"
a.b.c
$ echo "$string2"
txt

I would have used parameter expansion (if the shell supports it) :

$ name='a.b.c.txt'
$ string1="${name%.*}"
$ string2="${name##*.}"
$ echo "$string1"
a.b.c
$ echo "$string2"
txt

Tags:

Shell

Cut