{"id":3274,"date":"2019-06-19T23:56:43","date_gmt":"2019-06-19T15:56:43","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=3274"},"modified":"2019-06-19T23:56:44","modified_gmt":"2019-06-19T15:56:44","slug":"declare","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/declare","title":{"rendered":"declare\u547d\u4ee4 – \u58f0\u660eshell\u53d8\u91cf"},"content":{"rendered":"\n
declare\u547d\u4ee4\u7528\u4e8e\u5b9a\u4e49shell\u53d8\u91cf\uff0c\u4f46declare\u5b9a\u4e49\u7684\u53d8\u91cf\u4ec5\u80fd\u5728\u5f53\u524dshell\u73af\u5883\u4e2d\u8d77\u4f5c\u7528\uff0c\u5207\u6362shell\u73af\u5883\u540e\u5c06\u65e0\u6548\u3002<\/p>\n\n\n\n
\u8bed\u6cd5\u683c\u5f0f: <\/strong> declare [\u53c2\u6570] [\u76ee\u5f55] <\/p>\n\n\n\n \u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n \u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n \u663e\u793a\u5df2\u5b9a\u4e49\u7684\u53d8\u91cf\uff1a<\/p>\n\n\n\n \u5b9a\u4e49\u65b0\u7684Shell\u53d8\u91cf\uff1a<\/p>\n\n\n\n \u4f7f\u7528\u201c-i\u201d\u5b9a\u4e49\u65b0\u7684\u53d8\u91cf\uff1a<\/p>\n\n\n\n \u4f7f\u7528\u201c-p\u201d \u663e\u793a\u53d8\u91cfvar1\u548cvar2\u7684\u5b9a\u4e49\uff1a<\/p>\n\n\n\n \u663e\u793a\u6240\u6709\u7684\u73af\u5883\u53d8\u91cf\uff1a<\/p>\n\n\n\n declare\u547d\u4ee4\u7528\u4e8e\u5b9a\u4e49shell\u53d8\u91cf\uff0c\u4f46declare\u5b9a\u4e49\u7684\u53d8\u91cf\u4ec5\u80fd\u5728\u5f53\u524dshell\u73af\u5883\u4e2d\u8d77\u4f5c\u7528\uff0c\u5207\u6362sh […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3274"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=3274"}],"version-history":[{"count":2,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3274\/revisions"}],"predecessor-version":[{"id":3331,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/3274\/revisions\/3331"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=3274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=3274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=3274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}-a<\/td> \u58f0\u660e\u6570\u7ec4\u53d8\u91cf<\/td><\/tr> -f<\/td> \u4ec5\u663e\u793a\u51fd\u6570<\/td><\/tr> -F<\/td> \u4e0d\u663e\u793a\u51fd\u6570\u5b9a\u4e49<\/td><\/tr> -i<\/td> \u5148\u8ba1\u7b97\u8868\u8fbe\u5f0f\uff0c\u628a\u7ed3\u679c\u8d4b\u7ed9\u6240\u58f0\u660e\u53d8\u91cf<\/td><\/tr> -p<\/td> \u663e\u793a\u7ed9\u5b9a\u53d8\u91cf\u7684\u5b9a\u4e49\u7684\u65b9\u6cd5\u548c\u503c\uff0c\u5f53\u4f7f\u7528\u6b64\u9009\u9879\u65f6\uff0c\u5176\u4ed6\u7684\u9009\u9879\u5c06\u88ab\u5ffd\u7565<\/td><\/tr> -r<\/td> \u5b9a\u4e49\u53ea\u8bfb\u53d8\u91cf<\/td><\/tr> -x<\/td> \u5c06\u6307\u5b9a\u7684Shell\u53d8\u91cf\u8f6c\u6362\u6210\u73af\u5883\u53d8\u91cf<\/td><\/tr><\/tbody><\/table>\n\n\n\n [root@linuxcool ~]# declare <\/pre>\n\n\n\n
[root@linuxcool ~]# declare var1=\u201chello\u201d<\/pre>\n\n\n\n
[root@linuxcool ~]# declare -i var2=100+200<\/pre>\n\n\n\n
[root@linuxcool ~]# declare -p var1 var2<\/pre>\n\n\n\n
[root@linuxcool ~]# declare -x<\/pre>\n","protected":false},"excerpt":{"rendered":"