Need a help in shell script

Your requirement is a little bit different as the original.
In the original data file a, the was no space after the seached string(cool: ), and no other texte after the the seached keyword string.

Try the following script :

awk '
   NR==FNR {
      keys[$1]++;
      next;
   }
   /^\/\* -+[[:space:]]*.*[[:space:]]*-+ \*\/[[:space:]]*$/ {
      k = $0;
      gsub(/^\/\* --*[[:space:]]*|[[:space:]]*--* \*\/[[:space:]]*$/, "", k)
      display = (k in keys ? 1 : 0);
   }
   display
    ' b a

Jean-Pierre.

Thanks .. is this script search for the Key insert ??

No, this script search the string in the comment.

Jean-Pierre.

I used the exact code and the exact input files .. but no output generated .. Any issues from my side .. can you also please chk from your end

Thanks

I tried the code Jean-Pierre posted with your sample files and it works as expected.

P.S. If you have GNU Awk :slight_smile:

awk 'NR==FNR{x[$0"-----------------"];next};$2 in x' b RS="/[*] -" a

i am using a Sun Solaris any idea which will work

/usr/xpg4/bin/awk

when i use awk it throes me awk:bailing out error

when i use nawk it works fine which means no errors .. but no output generated

can you expand your code and need to print the lines

any thing which i need to change in the code

Please let me know

Thanks

Did you try /usr/xpg4/bin/awk?

how to use this one

not sure to implement

Just put /usr/xpg4/bin/awk instead of awk in front of the code :slight_smile:

P.S. Given your examples, this should work with nawk:

nawk 'NR==FNR{x[$0];next};/^\/\*/{f=0}
$2 in x{print;f=1;next};f' b FS="--* " a

Thanks aigles,radoulov it worked

:slight_smile:

Just curious if you guys explain me the code :slight_smile:

Thanks