Pattern search using grep command !

Hi,
I am trying to do pattern search using grep command. But i donot know what mistake i'm doing. I am not getting the expected Result. could any one please help me out?

[root work/tmp]$ cat b.ksh
AasdjfhB
57834B
86234B
472346B

I want to print the line which is starting with either A or 8 and ending with B. My expected result should be

AasdjfhB
86234B

I have tried with grep command but getting unexpected result,

[root work/tmp]$ grep '[^A8]B' b.ksh
AasdjfhB
57834B
86234B
472346B
$ grep '^[A8].*B$' file
AasdjfhB
86234B

Hi,
I have tried this. But it is not working. I am not getting any result.

[root work/tmp]$ grep '[^A8].*B$' k.ksh
[root work/tmp]$

Note position of Circumflex(^) in my code which matches regular expression at the beginning of the line

Circumflex (^) as the first character in the brackets reverses the sense: it matches any one character not in the list

$ grep '^[A8].*B$' file
AasdjfhB
86234B

This is also not working :confused:

[^a-c]

-- A

^ 

inside

 [ ]

negates the pattern like

[^a-c]

which means anything other than a till c

^[a-c] 

means any pattern starting either with

a,b or c

Hi all,
Thank you . It is working fine now.:slight_smile:
could you please tell me what is the meaning of the symbol "." in

grep '^[A8].*B$' b.ksh

. represent any character
The * behind makes it repeat.

Whit awk

awk '/^[A8].*B$/' infile

. Match any single character

Thank you all.

"." matches a single character and when combined with "*" mean any number of character