scripting problem

HI

-rw-r--r-- 1 synapse synapse 5242816 Jan 14 22:02 SMSCLOG.25
-rw-r--r-- 1 synapse synapse 1224138 Jan 14 22:14 SMSCLOG.26

below is the file which are generated after every 10 mins
i am trynig do scripting in which latest generated file get cta and give ouput

I use the below code

cd path; ls -lrt | tail -1 | awk '{print $9}'

output:

SMSCLOG.26

now i want the code by using which i can automate the tailing of this file if

what command i can use so that latest generated file get automatically tailed ............and i can read the ou

If you only need the filename then there is no need to use the -l flag on ls, which also saves you have to pipe to awk.

tail `cd path; ls -rt | tail -1`

Using backticks (`) will execute the commands between them and then substitute them with their output. So in the above the name of the most recently modified file in path will be passed as the parameter to tail.