I have spent hours on this but can't crack it. I am using sed on OSX .
This is the code:
sed -i.bak "s/^\(\$dokuwiki_hash.*\)$/\1\n '"$date"' => '"$hash"',/" install.php And the output that I get which is wrong is (see the first line):
$dokuwiki_hash = array(n '2013-03-17' => '7b62b75245f57f122d3e0f8ed7989623', '2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7', '2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc', '2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc', '2006-11-06' => 'b3a8af76845977c2000d85d6990dd72b', '2007-05-24' => 'd80f2740c84c4a6a791fd3c7a353536f', '2007-06-26' => 'b3ca19c7a654823144119980be73cd77', '2008-05-04' => '1e5c42eac3219d9e21927c39e3240aad', '2009-02-14' => 'ec8c04210732a14fdfce0f7f6eead865', '2009-12-25' => '993c4b2b385643efe5abf8e7010e11f4', '2010-11-07' => '7921d48195f4db21b8ead6d9bea801b8', '2011-05-25' => '4241865472edb6fa14a1227721008072', '2011-11-10' => 'b46ff19a7587966ac4df61cbab1b8b31', '2012-01-25' => '72c083c73608fc43c586901fd5dabb74', '2012-09-10' => 'eb0b3fc90056fbc12bac6f49f7764df3', '2013-04-06' => '7b62b75245f57f122d3e0f8ed7989623', ); It should be on a new line like below:
$dokuwiki_hash = array( '2013-03-17' => '7b62b75245f57f122d3e0f8ed7989623', '2005-09-22' => 'e33223e957b0b0a130d0520db08f8fb7', '2006-03-05' => '51295727f79ab9af309a2fd9e0b61acc', '2006-03-09' => '51295727f79ab9af309a2fd9e0b61acc', '2006-11-06' => 'b3a8af76845977c2000d85d6990dd72b', '2007-05-24' => 'd80f2740c84c4a6a791fd3c7a353536f', '2007-06-26' => 'b3ca19c7a654823144119980be73cd77', '2008-05-04' => '1e5c42eac3219d9e21927c39e3240aad', '2009-02-14' => 'ec8c04210732a14fdfce0f7f6eead865', '2009-12-25' => '993c4b2b385643efe5abf8e7010e11f4', '2010-11-07' => '7921d48195f4db21b8ead6d9bea801b8', '2011-05-25' => '4241865472edb6fa14a1227721008072', '2011-11-10' => 'b46ff19a7587966ac4df61cbab1b8b31', '2012-01-25' => '72c083c73608fc43c586901fd5dabb74', '2012-09-10' => 'eb0b3fc90056fbc12bac6f49f7764df3', '2013-04-06' => '7b62b75245f57f122d3e0f8ed7989623', ); Any help would be greatly appreciated !