Grep-tastic!

Simple problem:

Show me the lines of code in a file that have opening parentheses without closing parentheses. Nested and multiple parens need not be considered.

My solution:

  • grep "(" testfile | grep -v ")"

Better solution:

  • grep '([^)]*$' testfile
This entry was posted in computers/programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *