Re: put find output in an array

johnmmcparland wrote:
Hi all,

I have a script which finds all the files edited x days ago.

Having found these files, I wish to loop round them, check their name,
and if they do not have the same name as the script, remove them.

My probelm is once I've executed the find command;

find . -mtime ${maxTime}

how do I get this into an array?

After this I would do something like

for f in $array

where $array is the array containing the find output


find . -type f -mtime ${maxTime} ! -name ${badname} -exec rm {} ';'


find . -type f -mtime ${maxTime} |
while read name
#something with "$name"


array=( $(find . -type f -mtime ${maxTime}) )

for f in ${array[*]}
#something with "$f"

Relevant Pages

  • Re: Logon script - function array and select case not working
    ... this all works well, except, the function i am using for the rules in the control script causes alot of querrys to AD. as there are alot of groups. ... objTSout.writeline retrv ... So if you think that this will assign an array value to the variable, how do you think the case select statement is going go compare this array value with the literal string values such as "group name here"? ... However, by not assigning ANY value to checkgrp in the function, you are guaranteeing that, should the function ever exit, it will return no information. ...
  • Re: Perl: Subroutines and use of the "GD::Graph::bars;" Module
    ... I have been looking at the script once again, I could not really get your suggestion to work, but I have been doing some new changes thought. ... @array = sort @array; ... sub verbose { ... Global symbol "$title" requires explicit package name at ./ line 53. ...
  • Re: string retrieval issue
    ... Chicago Bears|NFC North ... not writing the third element back to the array). ... You didn't include it in your script. ... Fear is the mind-killer. ...
  • Re: Perl: Subroutines and use of the "GD::Graph::bars;" Module
    ... I did what you told me, but I just gets this error msg in return when I am trying to execute the script: ... And I also get this error msg even when I am not commenting out the settings around line 93? ... @array = sort @array; ... sub verbose { ...
  • Re: even rows for checkbox forms with no splitting of boxes from values
    ... 'mod' on the array length with a denominator equal to the width of the row, ... State saving really depends on what the script is already doing. ... So I usually roll my own checkboxes. ... #this is to create an array with 25-50 strings 2-10 in length ...