Advance string pattern search Please

Here is my problem..

  1. I want to search all those files with file name starting AJ128****
    (in all the sub directories also)
  2. I want to search for the follwoing type of string
    line beging with string - 'AK*any_1_char*any_2_char*510'
  3. I need to display list of file names
  4. I need to display total number of files that have the above string

Thanks for the help in advance. I am using sun solaris.

find . -type f -name "AJ128*"

check the options of find commands to know more details

grep 'AK*any_1_char*any_2_char*510' *

This will search the given string in all files present in current directory

grep -H 'AK*any_1_char*any_2_char*510' *

-h option shows filename on every line. To show only filenames where match is found, use:

grep -H ha * | cut -d ":" -f1 | uniq
grep -H ha * | cut -d ":" -f1 | uniq | wc -l

Yogesh.. Thanks for the reply..

any_1_char mean = > it can be Y or N or 1 etc
any_2_char means => it can be 18, 21, 01.. etc

So for the follwing 'AK*any_1_char*any_2_char*510', I am using regular expression. Like below.

find . -name AJ128\* -exec /usr/xpg4/bin/grep -il -E 'AK\*N\**\*510' {} \; | wc -l

But it was not working.

  1. And I want to retrieve all file names with all the conditions
  2. And I want to retrieve total no of files with all the conditions

Thanks for the help..