regex - How does this sed command parse numbers with commas? -


i'm having difficulty understanding number-parsing sed command saw in this article:

sed -i ':a;s/\b[0-9]\{3\}\>/,&/;ta' numbers.txt 

i'm sed newbie, i've been able figure out:

  • & adds what's there rather substitutes
  • the :a; ... ;ta calls substitution recursively on line until search finds no more returns

here's hoping folks can explain

  • what -i do? can't seem find on man pages though i'm sure it's there.
  • i'm little fuzzy on \b accomplishing here? perhaps helps left-right parsing priority, don't see how. lastly...
  • most importantly, why execute right left instead of left right? example, part of command keeps doing like: 1234566778,9 ---> 1234,566,778,9

the matching greedy, i.e. matches leftmost 3 digits not preceded word boundary , followed word boundary, i.e. rightmost 3 digits. after inserting comma, "goto" makes match again, comma introduced new word boundary, match happens earlier.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -