regex - How to exclude part of regexp with grep -


hi suppose have following output 'some_command':

dependency archy@0.0.2 dependency bower-config@~0.5.2 dependency bower-endpoint-parser@~0.2.2 dependency bower-json@~0.4.0 dependency bower-logger@~0.2.2 dependency bower-registry-client@~0.2.0 dependency cardinal@0.4.0 dependency chalk@0.5.0 dependency chmodr@0.1.0 dependency decompress-zip@0.0.8 dependency fstream@~1.0.2 dependency fstream-ignore@~1.0.1 dependency glob@~4.0.2 dependency graceful-fs@~3.0.1 dependency handlebars@~2.0.0 dependency inquirer@0.7.1 dependency insight@0.4.3 dependency is-root@~1.0.0 dependency junk@~1.0.0 dependency lockfile@~1.0.0 dependency lru-cache@~2.5.0 dependency mkdirp@0.5.0 dependency mkdirp@^0.5.0 dependency chalk@^0.5.0 dependency graceful-fs@~3.0.1 dependency mkdirp@~0.5.0 dependency mkdirp@^0.5.0 

what want library name including version without 'dependency' part. i'm using:

> some_command | grep -ioe '(?:dependency )(.+)' 

a non-capturing group should have ignored 'dependency' part, isn't.

what doing wrong? (i'm on mac os x yosemite)

#edit

in case might benefit resolving th similar mac os x grep problems, here link of choice: http://www.heystephenwood.com/2013/09/install-gnu-grep-on-mac-osx.html

non-capturing groups not available in grep. can use look-behind -p perl regexp:

grep -pio '(?<=dependency )(.+)' 

executing against file input, returns:

archy@0.0.2 bower-config@~0.5.2 bower-endpoint-parser@~0.2.2 bower-json@~0.4.0 bower-logger@~0.2.2 ... 

since don't have -p, can use either of these other approaches (among others!):

sed '/^dependency/s/^dependency //' awk '/^dependency/ {print $2}' 

they printing comes after dependency if line starts string.


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -