Moving cat values to a variable

I have a file created as ABC!DEF@2014.txt

My if condition is based on 2014 so I need to move it to variable.

So while I can do this on console screen -

 ls ABC* -l > test.txt
cat test.txt | cut -f 2 -d "@" | cut -f 1 -d "." 

to get the value - 2014
I am a bit at loss how to achieve this in a bash script.

VAR=$(cat test.txt | cut -f 2 -d "@" | cut -f 1 -d ".")

to check:

 echo $VAR 

What happens if ABC* matches more than one file..

A tighter search and allowing for multiple files matching ABC*@*.txt and avoiding a UUOC in ksh:-

for file in ABC*@*.txt
do
   tfile="${file%.txt}"
   tfile="${tfile#*@}"

   echo "I've found a match for $tfile in $file"
done 

Does that help, or just confuse?

Robin

Longhand using CygWin default bash terminal...

AMIGA:~> cd /tmp
AMIGA:/tmp> > 'ABC!DEF@2014.txt'
AMIGA:/tmp> var=`ls 'ABC!DEF@2014.txt'`
AMIGA:/tmp> echo "${var:$((${#var}-8)):4}"
2014
AMIGA:/tmp> _