Artificial intelligent assistant

Ignore lines that start with two possible patterns I'm trying to analyse a source code and output each different function or subroutine to a file. My problem is that the source code can be something like this: SUBROUTINE ABC --- END SUBROUTINE --- #SUBROUTINE to compute... SUBROUTINE Dummy --- WRITE SUBROUTINE XX has finished... END SUBROUTINE So, I am able to avoid the commented lines with the following command. awk 'BEGIN{IGNORECASE=1};/^[^#]*subroutine/{flag=1;s="tmp_s_"++i}/end subroutine/{flag=0} flag {print $0 > s}' $sourcecodefile But I want to avoid also the lines that have WRITE before the word Subroutine. I try this command but it doesn't work properly: awk 'BEGIN{IGNORECASE=1};/[^#|WRITE]*subroutine/{flag=1;s="tmp_s_"++i}/end subroutine/{flag=0} flag {print $0 > s}' $sourcecodefile

Perhaps use two conditions instead of one:


... /^[^#]*subroutine/ && $0 !~ /write subroutine/ ...

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy f84c7e8981c4a2b5edd5a06257c2bd8f