list file content as individual variables

Hello,

I've created a couple of files within a list using the command "ls -ltr | tail -2 > list" These files are the newest files placed within a directory. From the "list" file, I need to place the filenames as a variable. In which the newest file will be called "new_ctrl" the older file called "old_ctrl".

Here is the "list" input file (after using awk to list the date & filename):
Sep 12 11:06 cms38_Sep12.log
Sep 29 11:29 cms38_09_25_09.log

What I need:
new_ctrl="cms38_09_25_09.log"
old_ctrl="cms38_09_25_09.log"

I'm using BSH.

Your help would be greatly appreciated here.

Thank you for your time.
Pete

---------- Post updated at 09:43 AM ---------- Previous update was at 09:42 AM ----------

Sorry - Mistake on ctrl file output:

new_ctrl="cms38_09_25_09.log"
old_ctrl="cms38_Sep12.log"

Hi.

read old_ctrl new_ctrl <<< $(ls -tr | tail -2)

(for ksh...)

echo $(ls -tr | tail -2) | read old_ctrl new_ctrl

Thanks for your response. For the first code, there were no files that were created. Although there were no error messages. What am I missing?

Thanks Again!

Hi.

Actually this was to bypass the need to create the file.

But if you still want to create it then:

ls -tr | tail -2 > list
read old_ctrl new_ctrl < $(cat list)

(perhaps there's a better way than using cat - I'm more of a ksh person!)

Thanks!

I think I got it. I appreciate your input. You got me out of a jam!