Skip to main content
4 of 4
deleted 1 character in body
Stéphane Chazelas
  • 585.1k
  • 96
  • 1.1k
  • 1.7k

\w match "word" symbols (letters, digits and underscore) but in your example there is / after com which is not :alnum: so your pattern match nothing == empty output.

You can add / to pattern and look what is happend:

grep -oP 'com/\K\w+'

FYR -P option is experimental and can do which not expected in more systems, so you can do your task in other way:

sed "/com/s/.*\/\(\w\+\).\?$/\1/" 
Costas
  • 15k
  • 24
  • 38