I have primary files array and secondary files array in shell script. Both these arrays will contain file numbers.
#!/bin/bash
pri=(958 955 675 703 936 933 930 927 908 905 902 899 709)
snd=(953 947 943 939 916 915 1023 889 1010 1054 977 970 966)
# directories where we need to compare
primary=/primaries
secondary=/secondaries
echo "primary files: ${pri[@]}"
echo "secondary files: ${snd[@]}"
# now compare files in primary array `pri[@]` with `/primaries` directory. All files in primary array should be present in `/primaries` directory.
# and compare secondary array `snd[@]` with `/secondaries` directory. All files in secondary array should be present in `/secondaries` directory.
# If any of the file is missing, log a message.
Now all the files in primary array pri[@] should be present in /primaries directories and all the files in secondary array snd[@] should be present in /secondaries directories. File name is like this in both the directories proc_1041_test.data. Here 1041 is the file number.
How can I compare primary array file number with files in primaries directories and similarly for secondaries as well?
Note: /primaries and /secondaries directories can have sub directories in them so I just need to look for files in those two parent directories only not in any of the sub directories.