[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: script line not working as its supposed to, but why?



On 11/12/13 22:14, Sharon Kimble wrote:
> On Wed, 11 Dec 2013 21:58:19 +1100
> Scott Ferguson <scott.ferguson.debian.user@gmail.com> wrote:
> 
>> On 11/12/13 21:45, Sharon Kimble wrote:
>>> I have this line in a bash script that is not doing what its
>>> supposed to - 
>>> 'find /home/boudiccas/.fluxbox -type f -mtime +"$num" -name 'menu-*'
>>> -delete'
>>> where "$num" = 7 and 'menu-*'=menu-20131209-11:05 . Obviously the
>>> date and time can be different in each case, so how do I get it so
>>> that it deletes the menus if their number is greater than 7 please?
>>
>> That's the tricky part. As it stands the "menu" is just a string
>> *not* a value. Either convert it into a value or use another method
>> to determine which menu to delete (hint: creation date).
> 
> But there is no consistency with the creation date, the menu itself is
> regenerated whenever I install a new programme, and the old menu is
> saved with the suffix of the date and time. This could happen several
> times a day, or just once a week, there is no pattern to it. 
> 
> Or am I missing something obvious? :)

Each menu (like any file) has a creation date. You can use ls to list
according to creation date, which allows you to delete all but the most
recent 7 menu files.

> 
> Sharon.
> 

I see Gian and Mathias have already provided solutions.

Kind regards


Reply to: