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
do
....
done

where $array is the array containing the find output

thanks


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

===

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

===

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

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



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. ...
    (microsoft.public.scripting.vbscript)
  • 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 ./bars.pl line 53. ...
    (perl.beginners)
  • 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. ...
    (comp.lang.perl.misc)
  • 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 { ...
    (perl.beginners)
  • Re: settimeout needs alert() ???
    ... function slider { ... and use script to replace the src and title attributes. ... are downloaded completely. ... The usual strategy is to load all of the images in to an array of image ...
    (comp.lang.javascript)