{"id":5177,"date":"2015-09-03T09:57:29","date_gmt":"2015-09-03T01:57:29","guid":{"rendered":"http:\/\/rmohan.com\/?p=5177"},"modified":"2015-09-03T09:57:29","modified_gmt":"2015-09-03T01:57:29","slug":"shell-script-arrays-syntax-error-unexpected","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=5177","title":{"rendered":"Shell script arrays Syntax error: \u201c(\u201d unexpected"},"content":{"rendered":"<p>Recently when I am using arrays in a script I got the error message as <strong>\u201cShell script arrays Syntax error: \u201c(\u201d unexpected\u201d<\/strong>.<\/p>\n<p><strong>$ sh <span class=\"skimlinks-unlinked\">arrays.sh<\/span><\/strong> \u00a0#In <span class=\"skimlinks-unlinked\">arrays.sh<\/span> script I defined some arrays trying to extract values form it<\/p>\n<p>The out put I got after running the script is below<\/p>\n<p><strong>Shell script arrays Syntax error: \u201c(\u201d unexpected<\/strong><\/p>\n<p>I am struggled a bit to resolve this issue, and the solution I got to know is,\u00a0most probably in your OS the bash version is updated.<\/p>\n<p>So it is unable to resolve the array assignment.<\/p>\n<p>To fix the issue use bash instead of using sh while executing the script, that should not throw any syntax error.<\/p>\n<p><strong>Example:\u00a0<\/strong><\/p>\n<p>Run <span class=\"skimlinks-unlinked\">arrays.sh<\/span> as<\/p>\n<p><strong>$ bash <span class=\"skimlinks-unlinked\">arrays.sh<\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently when I am using arrays in a script I got the error message as \u201cShell script arrays Syntax error: \u201c(\u201d unexpected\u201d.<\/p>\n<p>$ sh arrays.sh #In arrays.sh script I defined some arrays trying to extract values form it<\/p>\n<p>The out put I got after running the script is below<\/p>\n<p>Shell script arrays Syntax error: \u201c(\u201d [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5177"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5177"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5177\/revisions"}],"predecessor-version":[{"id":5178,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/5177\/revisions\/5178"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}