Script to untar latest tar file

I am trying to put together a script that will check for the latest file in a directory then extract it. The extraction and the scheduling I can do, but am not sure how to get it to check for the latest file.
These files are uploaded every evening by an external party and the previous days files are not deleted automaticaly.

Any help would be appreciated.

ls -1t | head -n 1

'ls -t' lists all the file names in TIME order, newest on TOP... Or you can use 'ls -tr' which puts the newest on the bottom.... either way....

"ls -t | head -1" will yeild the newest file.... same as "ls -tr | tail -1"

Your choice...

Thanks, but how would I use this in a script??