How to print range of lines using sed when pattern has special character "["

Hi,

My input has much more lines, but few of them are below

        pin(IDF[3]) {
                direction       :       input;
                drc_pinsigtype  :       signal;
        pin(SELDIV6) {
                direction       :       input;
                drc_pinsigtype  :       signal;

And i want output:

        pin(IDF[3]) {
                direction       :       input;
                drc_pinsigtype  :       signal;
        pin(SELDIV6) {

In my script:

set pinname = "IDF[3]"
sed -n "/$pinname/,/pin/p" <inputfile>

but above command is giving error because of the presence of special character "[" & "]".

Where i am doing mistake, please let me know.

Use \[ and \] instead.

No, I cant use \[, \] as these values are stored in a variable in very early stages. Please give me another solution

"[" and "]" are the part of regular expressions. You must have to escape their special meaning. one way is to use another (modified) variable.

see this thread for more details.