|
|
Last modified file in a Subvolume #2
Hi Guys,
Can we get the file name of the Last Modified one from a particular
subvolume.. I know it can be done with few number of steps, but im
looking for something rather easier. It will be great if somebody can
help me out with this
|
|
0
|
|
|
|
Reply
|
Manu
|
2/8/2011 12:27:27 PM |
|
Manu wrote:
> Hi Guys,
>
> Can we get the file name of the Last Modified one from a particular
> subvolume.. I know it can be done with few number of steps, but im
> looking for something rather easier. It will be great if somebody can
> help me out with this
I think there is no single command to do that in TACL.
If you were asking about finding the latest file in an OSS directory, I think that could be done pretty easily:
latest=`ls -t dir_path | head -n 1`
or something close to that. I don't know whether you could do something similar for a Guardian subvol from TACL using the OSH command:
OSH/OUTV latest/ -c "ls -t /G/vol/subvol ~| head -n 1"
I cannot tell from the manual whether OSH can be used with OUTV, and I cannot tell from the manual whether ls -t does the right thing if you use it with a Guardian subvol. You might experiment a little with that if you have OSS on your system.
The pure TACL solution isn't short, but I am pretty sure this will find the file with the most recent modification time:
[#def latest_file routine |body|
#frame
#push latest
#push filename
#push thismod
#push thisfile
#push subvol
#set latest 0
[sink [#argument/text subvol/subvol]]
[#set thisfile [#filenames/maximum 1/ [subvol].*]]
[#loop |while| not [#emptyv thisfile]
|do|
[#set thismod [#fileinfo/modification_lct/ [thisfile]]]
[#if [#compute thismod > latest] |then|
[#set filename [thisfile]]
[#set latest [thismod]]
]
[#set thisfile [#filenames/maximum 1,previous [thisfile]/ [subvol].*]]
]
[#result [filename]]
#unframe
]
Except for typos, I think the above will do what you want. I cannot think of a shorter way to do it right now. If I'm overlooking something, I hope someone else will give a better solution.
You would run it like this:
#push x
[#set x [latest_file $vol.subvol]]
and it would put into x the full filename of the file in $vol.subvol that has the most recent modification time. If the subvolume contains no files, I think that x would be empty. Check that if it is important to how you want to use it.
|
|
0
|
|
|
|
Reply
|
Keith
|
2/8/2011 2:14:28 PM
|
|
Keith Dick wrote:
> Manu wrote:
>> Hi Guys,
>>
>> Can we get the file name of the Last Modified one from a particular
>> subvolume.. I know it can be done with few number of steps, but im
>> looking for something rather easier. It will be great if somebody can
>> help me out with this
>
> I think there is no single command to do that in TACL.
>
> If you were asking about finding the latest file in an OSS directory,
> I think that could be done pretty easily:
>
> latest=`ls -t dir_path | head -n 1`
>
> or something close to that. I don't know whether you could do
> something similar for a Guardian subvol from TACL using the OSH
> command:
>
> OSH/OUTV latest/ -c "ls -t /G/vol/subvol ~| head -n 1"
>
> I cannot tell from the manual whether OSH can be used with OUTV, and
It should, when using -osstty
OSH/OUTV latest/ 2>&1 -osstty -c "ls -t /G/vol/subvol ~| head -n 1"
> I cannot tell from the manual whether ls -t does the right thing if
> you use it with a Guardian subvol. You might experiment a little
It should, but only for physical volumes, not for virtual ones.
<snip>
Bye, Jojo
|
|
0
|
|
|
|
Reply
|
Joachim
|
2/9/2011 1:06:39 PM
|
|
On Feb 9, 6:06=A0pm, "Joachim Schmitz" <nospam.j...@schmitz-digital.de>
wrote:
> Keith Dick wrote:
> > Manu wrote:
> >> =A0Hi Guys,
>
> >> Can we get the file name of the Last Modified one from a particular
> >> subvolume.. I know it can be done with few number of steps, but im
> >> looking for something rather easier. It will be great if somebody can
> >> help me out with this
>
> > I think there is no single command to do that in TACL.
>
> > If you were asking about finding the latest file in an OSS directory,
> > I think that could be done pretty easily:
>
> > =A0 =A0latest=3D`ls -t dir_path | head -n 1`
>
> > or something close to that. =A0I don't know whether you could do
> > something similar for a Guardian subvol from TACL using the OSH
> > command: =A0
>
> > =A0 OSH/OUTV latest/ -c "ls -t /G/vol/subvol ~| head -n 1"
>
> > I cannot tell from the manual whether OSH can be used with OUTV, and
>
> It should, when using -osstty
>
> OSH/OUTV latest/ 2>&1 -osstty -c "ls -t /G/vol/subvol ~| head -n 1"
>
> > I cannot tell from the manual whether ls -t does the right thing if
> > you use it with a Guardian subvol. =A0You might experiment a little
>
> It should, but only for physical volumes, not for virtual ones.
>
> <snip>
>
> Bye, Jojo- Hide quoted text -
>
> - Show quoted text -
Thnx for the help.
|
|
0
|
|
|
|
Reply
|
Manu
|
2/10/2011 8:37:18 AM
|
|
|
3 Replies
317 Views
(page loaded in 0.083 seconds)
|
|
|
|
|
|
|
|
|