Get File Extension in BASH

The command basename is often used to extract the real file name without the file type specific file extension:

basename thisfile.txt .txt

thisfile
Now sometimes you need it the other way around, you might want to have the file extension. There are of course hundreds of ways to do so, but I found this one appealing since it also shows how the command awk works (which I should learn a bit better I think):

echo "thisfile.txt"|awk -F . '{print $NF}'

txt
The “-F” marks the delimiter, “$NF” means the last field generated. Seems to be a pretty straightforward tool.

Also

echo "thisfile.txt" | rev | cut -c 1-3 | rev