unix - Grep examples - can't understand -


given following commands:

ls | grep ^b[^b]*b[^b]  ls | grep ^b[^b]*b[^b]* 

i know ^ marks start of line, can give me brief explanation these commands? do? (step step)

thanks!

^ can mean 2 things:

  • mark beginning of line
  • or negates character set (whithin [])

so, means:

  • lines starting 'b'
  • matching (0+) characters other 'b'
  • matching 'b'
  • followed not-'b' (or nothing @ all)

it match

bb bzzzzzb bzzzzzbzzzzzzz 

but not

zzzzbb bzzzzzxzzzzzz 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -