{"id":1646,"date":"2014-11-30T13:16:20","date_gmt":"2014-11-30T13:16:20","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1646"},"modified":"2014-11-30T13:16:20","modified_gmt":"2014-11-30T13:16:20","slug":"bash%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%9a%84%e4%b8%80%e4%ba%9b%e7%bb%8f%e9%aa%8c%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1646.html","title":{"rendered":"Bash\u7684\u5b57\u7b26\u4e32\u7684\u4e00\u4e9b\u7ecf\u9a8c\u603b\u7ed3"},"content":{"rendered":"<p>\u5176\u5b9e\u8fd9\u7bc7\u7684\u5185\u5bb9\u6ca1\u591a\u5c11\uff0c\u5982\u679c\u81ea\u5df1\u5728\u5e73\u65f6\u7684\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u6bd4\u8f83\u6ce8\u610f\u7684\u8bdd\u4e5f\u4e0d\u4f1a\u78b0\u5230\u6211\u4e0b\u9762\u7684\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\uff0c\u65e2\u7136\u8ba9\u6211\u78b0\u5230\u4e86\uff0c\u90a3\u8fd8\u662f\u603b\u7ed3\u4e00\u4e0b\u5427\uff0c\u65b9\u4fbf\u4ee5\u540e\u53c2\u8003\uff0c\u4e0d\u8981\u518d\u5728\u540c\u6837\u7684\u95ee\u9898\u4e0a\u72af\u4f4e\u7ea7\u9519\u8bef\u4e86\u3002<\/p>\n<pre class=\"lang:default decode:true\">$\u00a0cat xxxxxxxxx.sh\n#!\/bin\/bash\ndt=$(date +%Y%m%d -d '-1 day')\nhost=\"www.ixyzero.com\"\n\necho $host_$dt.txt\necho $host$dt.txt<\/pre>\n<p># bash xxxxxxxxx.sh<br \/>\n20141124.txt<br \/>\nwww.ixyzero.com20141124.txt<\/p>\n<p>\u8fd9\u91cc$host\u548c$dt\u90fd\u662f\u5b57\u7b26\u4e32\u53d8\u91cf\uff0c\u76f4\u63a5\u8fde\u63a5\u5f53\u7136\u6ca1\u95ee\u9898\uff0c\u4f46\u662f\u770b\u4e0a\u53bb\u4e0d\u592a\u597d\u770b\uff0c\u5982\u679c\u662f\u60f3\u8bbe\u7f6e\u5206\u9694\u7b26\u7684\u8bdd\uff0c\u4e5f\u8bf7\u4e0d\u8981\u4f7f\u7528\u4e0b\u5212\u7ebf\u201c_\u201d\u5426\u5219\u5c31\u4f1a\u50cf\u4e0a\u9762\u90a3\u79cd\uff0c\u65e0\u6cd5\u8bc6\u522b$host_\u8fd9\u6837\u7684\u53d8\u91cf\uff08\u5b9e\u9645\u6d4b\u8bd5\u7684\u65f6\u5019\u53d1\u73b0\uff0c\u53ea\u8981\u4e0d\u4f7f\u7528\uff1a\u5b57\u6bcd\u3001\u6570\u5b57\u3001\u4e0b\u5212\u7ebf\u4f5c\u4e3a\u5206\u9694\u7b26\uff0c\u5c31\u4e0d\u4f1a\u9020\u6210\u4e0a\u9762\u7684\u90a3\u79cd\u56f0\u6270\uff0c\u6240\u4ee5\u53ef\u4ee5\u4f7f\u7528\u201c-\u201d\u66ff\u4ee3\u201c_\u201d\uff09<br \/>\n====<\/p>\n<pre class=\"lang:default decode:true\">$\u00a0cat xxxxxxxxx.sh\n#!\/bin\/bash\ndt=$(date +%Y%m%d -d '-1 day')\nhost=\"www.ixyzero.com\"\n\necho $host\"$dt\".txt\necho $host$dt.txt<\/pre>\n<p># bash xxxxxxxxx.sh<br \/>\nwww.ixyzero.com20141124.txt<br \/>\nwww.ixyzero.com20141124.txt<br \/>\n====<\/p>\n<pre class=\"lang:default decode:true\">$\u00a0cat xxxxxxxxx.sh\n#!\/bin\/bash\ndt=$(date +%Y%m%d -d '-1 day')\nhost=\"www.ixyzero.com\"\n\necho $host\"$dt\".txt\necho $host\"_\"$dt.txt\necho $host$dt.txt<\/pre>\n<p># bash xxxxxxxxx.sh<br \/>\nwww.ixyzero.com20141124.txt<br \/>\nwww.ixyzero.com_20141124.txt<br \/>\nwww.ixyzero.com20141124.txt<\/p>\n<p>\u4ece\u4e0a\u9762\u7684\u6d4b\u8bd5\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0c\u5728Bash\u91cc\uff0c\u5b57\u7b26\u4e32\u8fde\u63a5\u662f\u975e\u5e38\u76f4\u63a5\u7684\uff0c\u653e\u5728\u4e00\u8d77\u5c31\u662f\u5b57\u7b26\u4e32\u8fde\u63a5\uff1b\u5bb9\u6613\u51fa\u95ee\u9898\u7684\u5730\u65b9\u5728\u4e8e\u4e24\u4e2a\u53d8\u91cf\u4e4b\u95f4\u7684\u8fde\u63a5\uff0c\u6700\u597d\u4f7f\u7528\u53cc\u5f15\u53f7\u5206\u5f00\uff0c\u6216\u662f\u67d0\u4e2a\u522b\u7684\u7b26\u53f7\uff08\u6bd4\u5982\u6211<span style=\"color: #ff0000;\">\u5728\u8bbe\u7f6e\u67d0\u4e2a\u8def\u5f84\u4e3a\u53d8\u91cf\u7684\u65f6\u5019\uff0c\u4e00\u822c\u4e0d\u4f1a\u52a0\u4e0a\u6700\u540e\u7684&#8221;\/&#8221;\uff0c\u65b9\u4fbf\u540e\u9762\u5b57\u7b26\u4e32\u7684\u8fde\u63a5<\/span>\uff09\u3002<\/p>\n<p>====<\/p>\n<p>\u5c31\u7b97\u5728shell\u811a\u672c\u4e2d\u6307\u5b9a\uff1a<br \/>\ndate=201410*<br \/>\n\u5982\u679c\u662f\u5728\u547d\u4ee4\u884c\u4e2d\u7684\u8bdd\uff0c\u9700\u8981\u624b\u52a8\u5c06201410*\u4e2d\u7684*\u8fdb\u884c\u8f6c\u4e49\uff08*\uff09\uff1b\u5982\u679c\u662f\u5728\u811a\u672c\u4e2d\u7684\u8bdd\uff0c\u76f4\u63a5\u4f7f\u7528$date\u5373\u53ef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5176\u5b9e\u8fd9\u7bc7\u7684\u5185\u5bb9\u6ca1\u591a\u5c11\uff0c\u5982\u679c\u81ea\u5df1\u5728\u5e73\u65f6\u7684\u7f16\u7a0b\u8fc7\u7a0b\u4e2d\u6bd4\u8f83\u6ce8\u610f\u7684\u8bdd\u4e5f\u4e0d\u4f1a\u78b0\u5230\u6211\u4e0b\u9762\u7684\u8fd9\u4e2a\u95ee\u9898\uff0c\u4f46\u662f\uff0c\u65e2\u7136\u8ba9\u6211\u78b0\u5230\u4e86\uff0c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[83,19],"class_list":["post-1646","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","tag-bash","tag-tips"],"views":1956,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1646"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1646\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}