\u91cd\u547d\u540d\u53d8\u91cf<\/strong><\/div>\n\u5728\u7f16\u5199\u590d\u6742\u7684\u811a\u672c\u65f6\uff0c\u4e3a\u811a\u672c\u7684\u53c2\u6570\u6307\u5b9a\u540d\u79f0\u901a\u5e38\u5f88\u6709\u7528\uff0c\u800c\u4e0d\u662f\u7ee7\u7eed\u5c06\u5b83\u4eec\u79f0\u4e3a $1\u3001$2 \u7b49\u3002\u7b49\u5230\u7b2c 35 \u884c\uff0c\u9605\u8bfb\u4f60\u811a\u672c\u7684\u4eba\u53ef\u80fd\u5df2\u7ecf\u5fd8\u4e86 $2 \u8868\u793a\u4ec0\u4e48\u3002\u5982\u679c\u4f60\u5c06\u4e00\u4e2a\u91cd\u8981\u53c2\u6570\u7684\u503c\u8d4b\u7ed9 $filename \u6216 $numlines\uff0c\u90a3\u4e48\u4ed6\u5c31\u4e0d\u5bb9\u6613\u5fd8\u8bb0\u3002<\/p>\n
\r\n#!\/bin\/bash\r\nif [ $# -lt 2 ]; then\r\n echo \"Usage: $0 lines filename\"\r\n exit 1\r\nelse\r\n numlines=$1\r\n filename=$2\r\nfi\r\nif [[ $numlines != [0-9]* ]]; then\r\n echo \"Error: $numlines is not numeric\"\r\n exit 2\r\nfi\r\nif [ ! -f $ filename]; then\r\n echo \"Error: File $filename not found\"\r\n exit 3\r\nelse\r\n echo top of file\r\n head -$numlines $filename\r\nfi\r\n<\/pre>\n\u5f53\u7136\uff0c\u8fd9\u4e2a\u793a\u4f8b\u811a\u672c\u53ea\u662f\u8fd0\u884c head \u547d\u4ee4\u6765\u663e\u793a\u6587\u4ef6\u4e2d\u7684\u524d x \u884c\uff0c\u4f46\u5b83\u7684\u76ee\u7684\u662f\u663e\u793a\u5982\u4f55\u5728\u811a\u672c\u4e2d\u4f7f\u7528\u5185\u90e8\u53c2\u6570\u6765\u5e2e\u52a9\u786e\u4fdd\u811a\u672c\u8fd0\u884c\u826f\u597d\uff0c\u6216\u5728\u5931\u8d25\u65f6\u6e05\u6670\u5730\u77e5\u9053\u5931\u8d25\u539f\u56e0\u3002<\/p>\n
via: https:\/\/www.networkworld.com\/article\/3387154\/working-with-variables-on-linux.html#tk.rss_all<\/p>\n
\u4f5c\u8005\uff1aSandra Henry-Stocker \u9009\u9898\uff1alujun9972 \u8bd1\u8005\uff1aMjSeven \u6821\u5bf9\uff1awxy<\/p>\n
\u672c\u6587\u7531 LCTT \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd \u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"
\u6709\u8bb8\u591a\u91cd\u8981\u7684\u503c\u90fd\u5b58\u50a8\u5728 Linux \u7cfb\u7edf\u4e2d\uff0c\u6211\u4eec\u79f0\u4e3a\u201c\u53d8\u91cf\u201d\uff0c\u4f46\u5b9e\u9645\u4e0a\u53d8\u91cf\u6709\u51e0\u79cd\u7c7b\u578b\uff0c\u5e76\u4e14\u4e00\u4e9b\u6709\u8da3\u7684\u547d\u4ee4\u53ef\u4ee5\u5e2e […]<\/p>\n","protected":false},"author":1920,"featured_media":158821,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-158816","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1920"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=158816"}],"version-history":[{"count":7,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158816\/revisions"}],"predecessor-version":[{"id":159088,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/158816\/revisions\/159088"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/158821"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=158816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=158816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=158816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}