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
.