I'm copy a sed script form Ubuntu debian to osx but gettingRE error: repetition-operator operand invalidWhat is wrong?$ . sed_shorter_version_user_extensions_to_ruby.shsed: 22: ### DELETE whole lines ...: RE error: repetition-operator operand invalidInspecting 1 file......The script is:(I left the line numbers in in case the 22 means line 22).  1 sed '  2 ### DELETE whole lines  3 /\/\//d  4 /^$/d  5 ### CHANGE large chunks  6 s/^storedVars\[/  def /  7 s/SAD/sad/  8 s/HAPPY/happy/  9 s/\][[:space:]]*=[[:space:]]*/\ 10     / 11 s/;/\ 12   end\ 13 / 14 ### CHANGE small chunks 15 s/css=// 16 s/link=// 17 s/label=// 18 ### CHANGE specific lines 19 ### Scoped corrections for clarity 20 /def insurance_expiration/ { 21   /expiration_month/ { 22     s/value=.*\+1)/(Date.new + 1.month).strftime(%B)/ 23   } 24   /expiration_year/ { 25     s/value=.*FullYear())/(Date.new + 1.month).strftime(%Y)/ 26   } 27 } 28 ### Unable to combine these for the %B and %Y despite several tries mdd 9/13/2015 29 /Date.*new.*month/ { 30   s///g 31   s/%B/%B/ 32   s/%Y/%Y/ 33 } 34 /choose_submodel_text/ { 35   s/ \] =/\n    / 36 } 37 /email.*albert.*random/ { 38   s/(albert.*gmail\.com)/Faker::Internet.email/ 39 } 40 ' Variables/user-extensions.js | awk ' 41 ### ADD Header and footer 42 BEGIN { print # page object methods; print module PageObject # Variable values } 43       { print } 44 END { print end } '> rspec_conversions/new_page_object_methods.rb 45 rubocop -a rspec_conversions/new_page_object_methods.rb
Getting RE error: repetition-operator operand invalid on osx sed
shell;debian;sed;osx
s/value=.*\+1)/(Date.new + 1.month).strftime(%B)/          ^^^You have the * zero-or-more repetition operator followed by \+. The meaning of \+ depends on the version of sed. It might match + or \+, or it might be the one-or-more repetition operator. GNU sed treats \+ as the one-or-more repetition operator, except in a context where it wouldn't make sense, such as here, following another repetition operator. I think that OSX sed treats \+ as the one-or-more repetition operator, and complains here because two consecutive repetition operators doesn't make sense.In sed, to match +, write +.  Well, it would make sense, but all sequences of repetition operators except {} can be collapsed to a single one, so most regexp engines treat them specially.  