I need to open automatically files and analyse their content.
I'm struggling to find a way to open them due to the fact that in each folder there is different files with different naming patterns.
I only need to open files with a specific pattern : "error_YYYYMMDD_xyz.json" "xyz being a number from 0 to 999.
I was using this algorithm before my need to only search specific files:
for folder in `ls -d $path`
do
for file in `ls $folder`
do
erreur=`jq ".tot_type" $folder/$file`
date=`echo $folder/$file | cut -d '_' -f2 | cut -c7-8 `
if [ \( "$erreur" > 0 \) ]
then
j$date=`expr ${j$date} + 1`
fi
done
done
How can I make this work?
for file in $path/$folder/error_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]_[0-9]*.json; do youraction; done