I need to extract the file extension for the files in a directory, however the files are in the below format,
ab10001i.39400.8163.txt
ab10001i.39400.0433.txt
ab10001i.39400.24433.txt
ab10001i.39400.90631.TXT
I tried the below script , but didn't give me the expected results.. Any advise ? thank you!!
for file in "$SEARCH_DIR"/*; do
clmFile=`basename "$file"`
lastpart=``echo -n ${clmFile%.*} | tail -c4``
echo "TEST THIS THIS " $lastpart
if [ ${extension} == "TXT" ]; then
echo "TXT FILE"
elif [ ${extension} == "txt" ]; then
echo "txt FILE"
fi
done