please explain this

zsh 4.3.4% cat file
ACFCFACCACARCSHFARCVJVASTVAJFTVAJVGHBAJ
zsh 4.3.4% cat file1
A
C
F
R
zsh 4.3.4% <file1 while read;do printf "%s=%d\n" "$REPLY" "${#$(<file)//[^$REPLY]}";done
A=9
C=7
F=4
R=2

That was the previous post.
But , can anybody can explain me in detail about this line

zsh 4.3.4% <file1 while read;do printf "%s=%d\n" "$REPLY" "${#$(<file)//[^$REPLY]}";

i cannot understand how it is interpreted. Please explain me.

I suppose you mean this: "${#$(<file)//[^$REPLY]}" (the rest is quite trivial).

This is nested expansion that goes like this:

  1. $(<file) is equivalent to $(cat file) but a bit faster.
  2. ${$(<file)//[^$REPLY]} means: remove(substitute with null) any character different than the content of the variable REPLY.
  3. ${#$(<file)//[^$REPLY]} (the # sign) means: give me the number of characters in the variable ${$(<file)//[^$REPLY]}.

HTH

Thanks alot