{"id":1353,"date":"2013-04-24T13:45:43","date_gmt":"2013-04-24T11:45:43","guid":{"rendered":"http:\/\/blog.sfsoft.it\/?p=1353"},"modified":"2013-04-24T13:45:43","modified_gmt":"2013-04-24T11:45:43","slug":"conoscere-quanti-parametri-vengono-passati-ad-uno-script-in-bash","status":"publish","type":"post","link":"http:\/\/www.sfsoft.it\/blog\/2013\/04\/24\/conoscere-quanti-parametri-vengono-passati-ad-uno-script-in-bash\/","title":{"rendered":"Conoscere quanti parametri vengono passati ad uno script in BASH"},"content":{"rendered":"<p>Una chicca utile dal buon <a href=\"http:\/\/www.cyberciti.biz\/\" target=\"_blank\">nixCraft<\/a>, conoscere quanti parametri vengono passati ad uno script in bash:<\/p>\n<pre lang=\"bash\">#!\/bin\/bash\r\n# Purpose: Demo bash function\r\n# Author: nixCraft\r\n# -----------------------------\r\n\r\n## Define a function called foo()\r\nfoo(){\r\n  echo \"Function name:  ${FUNCNAME}\"\r\n  echo \"The number of positional parameter : $#\"\r\n  echo \"All parameters or arguments passed to the function: '$@'\"\r\n  echo\r\n}\r\n\r\n## Call or invoke the function ##\r\n## Pass the parameters or arguments  ##\r\nfoo nixCraft\r\nfoo 1 2 3 4 5\r\nfoo \"this\" \"is\" \"a\" \"test\"<\/pre>\n<p>Questi i risultati a video:<\/p>\n<pre lang=\"bash\">Function name: foo\r\nThe number of positional parameter : 1\r\nAll parameters or arguments passed to the function: 'nixCraft'\r\n\r\nFunction name: foo\r\nThe number of positional parameter : 5\r\nAll parameters or arguments passed to the function: '1 2 3 4 5'\r\n\r\nFunction name: foo\r\nThe number of positional parameter : 4\r\nAll parameters or arguments passed to the function: \u2018this is a test\u2018<\/pre>\n<p><a href=\"http:\/\/www.cyberciti.biz\/faq\/unix-linux-bash-function-number-of-arguments-passed\/\" target=\"_blank\">http:\/\/www.cyberciti.biz\/faq\/unix-linux-bash-function-number-of-arguments-passed\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Una chicca utile dal buon nixCraft, conoscere quanti parametri vengono passati ad uno script in bash: #!\/bin\/bash # Purpose: Demo bash function # Author: nixCraft # &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; ## Define a function called foo() foo(){ echo &#8220;Function name: ${FUNCNAME}&#8221; echo &#8220;The number of positional parameter : $#&#8221; echo &#8220;All parameters or arguments passed to the function: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15,3],"tags":[52,16,8],"_links":{"self":[{"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/posts\/1353"}],"collection":[{"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/comments?post=1353"}],"version-history":[{"count":1,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/posts\/1353\/revisions"}],"predecessor-version":[{"id":1354,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/posts\/1353\/revisions\/1354"}],"wp:attachment":[{"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/media?parent=1353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/categories?post=1353"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sfsoft.it\/blog\/wp-json\/wp\/v2\/tags?post=1353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}