I am new to programming and need to write a script that will check the following if.. else block and check if there is else statement present before the End IF.
This is the typical block structure that I want to check:
If condition [ Then ]
[ statements ]
[ ElseIf elseifcondition [ Then ]
[ elseifstatements ] ]
[ Else
[ elsestatements ] ]
End If
The script (could be a bash script for example) should go through the code recursively, searching code in all subfolders, and should output all such If.. End If blocks, where there is no else statement before End If. I tried this.
grep -Ern "If|ElseIf|End+If" . --include=*.fil
*.fil is the file type with code.
I can see some result, but is there a better way to do it? Also is it possible to have the output separated by a blank line after each if.. end if block is found?
Any, help will be greatly appreciated. Many thanks.
Aucun commentaire:
Enregistrer un commentaire