create file as variable for searching point

Hi Friends,

I need expert help:),

I have bellow script that function for searching string in multiple file,
the script is working well.
but I thing it still can be optimize since so many repetition in bellow command, where string that I marked BOLD italic is clue for what I am looking for

gzcat  radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz |  /tmp/find_ses.pl "510098810513720" >> temp/opera.log

is it possible to put clue in different file that the script refer to ?

the content of clue file only string that I want looking for :

 510098810513720
 510098810127652
 510098810129898
 etc
 etc

another question is =
2010062[0123456] to match date 20100620 until 20100626
how to match last 2 digit example from date 20100615 until 20100626
where 15-26 is variable

here is the full script

#!/bin/bash
array1=(12 58)
array2=(00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23)
for (( x=0; x<2; x++ )); do
for (( y=0; y<24; y++ )); do
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810513720" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810127652" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810129898" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810457113" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810133736" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098811104417" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810198601" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098811012483" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810389153" >> temp/opera.log
        gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "510098810473130" >> temp/opera.log
done
done

put patterns in a file (/tmp/patterns.txt)

$ echo "$(</tmp/patterns.txt)"
510098810513720
510098810127652
510098810129898
510098810457113
510098810133736
510098811104417
510098810198601
510098811012483
510098810389153
510098810473130
#!/bin/bash
array1=(12 58)
array2=(00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23)
while read pattern; do
   for (( x=0; x<2; x++ )); do
      for (( y=0; y<24; y++ )); do
         gzcat radacct/10.17.3.${array1[$x]}/detail-2010062[0123456]_${array2[$y]}.gz | /tmp/find_ses.pl "$pattern" >> temp/opera.log
      done
   done
done < /tmp/patterns.txt
1 Like

Hi daPeach,

The script is working great exactly as I want.

thank you very much.

maybe you or other can answer my second question ?

2010062[0123456] to match date 20100620 until 20100626
how to match last 2 digit example from date 20100615 until 20100626
where 15-26 is variable