Agnus Dei (jackal) wrote,
Agnus Dei
jackal

How to get around regex greediness

Fighting greediness in regular expressions is a pain in the ass. Period.

The following example will get everything after the JSESSIONID= in the access log up to the first space character

cat /var/log/httpd/access_log.2013-12-06.txt | egrep -o "JSESSIONID=[^[:space:]]*" 

  
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

  • 0 comments