Operating System - HP-UX
1832986 Members
2415 Online
110048 Solutions
New Discussion

Re: Refer to last *.aft file.

 
M Yasir Khan_1
Occasional Contributor

Refer to last *.aft file.

Hello all,

I have a software that takes the backup and generates the log of every backup in seperate file. usually this file is ????????.fnt and on wednesday it is ????????.fft (? is refering to random character).

now what i want to do is to send this file as email to myself and the backup administrator.

what i want to know is that how can i refer to the latest file which may be .fnt and .fft. I want its name to be appeared in the variable and then i'll use it in the script.

hope u ppl have understand my problem.

thanks in advance,

Yasir.
4 REPLIES 4
T G Manikandan
Honored Contributor

Re: Refer to last *.aft file.

you can use
#ls -t|head -1
to get the latest file from that dir

Elmar P. Kolkman
Honored Contributor

Re: Refer to last *.aft file.

Or, if there are more files in the directory:
VAR=$(ls -td ????????.fft ????????.fnt | head -1)

Every problem has at least one solution. Only some solutions are harder to find.
John Carr_2
Honored Contributor

Re: Refer to last *.aft file.

Yasir

I would look to change the s/w to create files with more meaningful name first but to answer your question

ls -tr | tail -1

what backup s/w are you using ?

John.
M Yasir Khan_1
Occasional Contributor

Re: Refer to last *.aft file.

Thanks alot for your helps ... I accomplished it with "FILE=`ls -t *.fnt *.fft |head -1`". and its working.

thanks to all of you.

Yasir.