Mike Plate

Freelance web and mobile developer

Extract regular expression group match using grep or sed

I've been looking for a GNU/Linux command that matches lines in a text file using a regular expression and extracts a group match for that expression (a sub-match within parenthesis). It would be really handy if the grep command supported this as an output option, but unfortunately it does not. However there are at least two ways to approach this problem. I'll show you one with grep and one with sed. Read more...


If you want to retrieve a single file from a specific repository without cloning or checking out anything, you can do this:

git archive --remote git@bitbucket.org:myusername/myrepo.git HEAD file-to-retrieve.rb | tar -x

Twitter: @mikeplate