Bash: Array empty outside of the for loop

I'm creating a script to rotate my backups, one important part of this script is to find the files based on certain criteria and then move them or erase them.

I'm creating a script to rotate my backups, one important part of this script is to find the files based on certain criteria and then move them or erase them.

I've got the loop going, but the Array (path_array), can't be used outside the loop. I've read several posts about this, but not sure how the answers apply to my specific case. See code below.

Thanks!!!

#!/bin/bash
anos=(2016 2017 2018 2019)
meses=(02)

meses=(01 02 03 04 05 06 07 08 09 10 11 12)
anos=(2018)

source="/volume1/NetBackup/Servers/MIA/"
destination="/volume1/NetBackup/Servers/MIA/_Archive"

######## Pasar los Files del Primer dia del Año a Archiving

for i in ${anos[@]}; do
for j in ${meses[@]}; do
month_start=$(date +$i-$j-01)
month_finish=$(date +$i-$j-02)
# echo $month_start
# echo $month_finish
path_array=(find $source -type f -not -path "*/_Archive/*" -newermt $month_start ! -newermt $month_finish | cut -sd / -f 6-)
# echo $path_array

    # echo Archivos año: $i mes: $j

    #printf '%s\n' "${path_array[@]}"
done

done

printf '%s\n' "${path_array[@]}"


How to group multiple sets of duplicate integers in an array into their own array of arrays?

I am trying to split an array of integers into an array of arrays by duplicate values. The original array is composed of a list of 6 digit integers, some of these integers come in pairs, others come in groups of 3 or 4s. I'd like to get these duplicates pushed to their own arrays and have all of these arrays of duplicates composed into an array of arrays that I can later loop through.

I am trying to split an array of integers into an array of arrays by duplicate values. The original array is composed of a list of 6 digit integers, some of these integers come in pairs, others come in groups of 3 or 4s. I'd like to get these duplicates pushed to their own arrays and have all of these arrays of duplicates composed into an array of arrays that I can later loop through.

I've looked on in the lodash library for some method or combination of but can't quite find anything that seems to work. I've also tried a few different configurations with nested for loops but also am struggling with that.

const directory = "X/";
let files = fs.readdirSync(directory);
let first6Array = [ ];
for(i=0; i< files.length; i++){
 let first6 = files[i].substring(0, 6);
 first6Array.push(first6);
};
console.log(first6Array);

example output of first6Array: [ '141848', '141848', '141848', '142851', '142851', '143275', '143275']

I'd like to end up with something like

let MasterArray = [[141848,141848,141848],[142851,142851],[143275,143275]];

For loop only gives the last value of an array

I've been trying to transpose a matrix (-like 2D array) in ES6 but the for loop only gives the last value of the original array and I have no idea what I did wrong.

I've been trying to transpose a matrix (-like 2D array) in ES6 but the for loop only gives the last value of the original array and I have no idea what I did wrong.

Suppose the size of the spectrum array is 128 x 128:

const width = 128;
const height = 128;

var spectrum: Complex[][] = fft(data);

// Transpose spectrum array
var transposedData: Complex[][] = new Array(height).fill(new Array(width));
for (let y = 0; y < height; y++) {
for (let x = 0; x < width; x++) {
const c = spectrum[x][y].deepCopy();
transposedData[y][x] = c;
}
}

spectrum = transposedData;
console.log(spectrum);

This gives me a 2D array, every element of which is the value of spectrum[127][127]. What have I done wrong?

Array of Arrays in Angular Class

I'm new to Angular and cant really grasp how to loop through an array inside an array.

I'm new to Angular and cant really grasp how to loop through an array inside an array.

I'm trying to achieve same thing as the following C code:

   for (int i = 0; i < 10; i ++){
       printf ("%d", ar[i]);
   for (int j =0; j &lt; 3; j ++ )
   {
       printf ("%d", arre[j]);
   }
   printf ("\n");

}

But in my case I have a class:

class Arende{
Id:number
Namn :string
Status :string
RegistreringLista :Registrering[]
}

HTML:

    <tr *ngFor="let arende of arenden">
<td> {{arende.Id}} </td>
<td> {{arende.Namn}}</td>
<td> {{arende.RegistreringLista.xxxx}}</td>
<td> {{arende.RegistreringLista.yyyy}}</td>
<td> {{arende.ResitreringsLista.zzzzz}}</td>

I thought that there should be some way to do a:

<tr *ngFor="let arende of RegistreingsLista">

But that dosen't seem right either ... I have trouble understanding the loop sequence ... How should I set it up?