{"id":203294,"date":"2020-10-27T09:31:11","date_gmt":"2020-10-27T01:31:11","guid":{"rendered":"https:\/\/gulass.cn\/?p=203294"},"modified":"2020-10-20T10:32:35","modified_gmt":"2020-10-20T02:32:35","slug":"linux-dax","status":"publish","type":"post","link":"https:\/\/gulass.cn\/linux-dax.html","title":{"rendered":"\u5728Linux\u884c\u5185\u76f4\u63a5\u8fdb\u884c\u5927\u5c0f\u5199\u8f6c\u6362"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u5728\u7f16\u8f91\u6587\u672c\u65f6\u5927\u5c0f\u5199\u5e38\u5e38\u662f\u9700\u8981\u6ce8\u610f\u7684\u5730\u65b9\uff0c\u5927\u5c0f\u5199\u7684\u8f6c\u6362\u662f\u5f88\u67af\u71e5\u800c\u7e41\u7410\u7684\u5de5\u4f5c\uff0c\u6240\u5e78\uff0cLinux \u63d0\u4f9b\u4e86\u5f88\u591a\u80fd\u8ba9\u8fd9\u4efd\u5de5\u4f5c\u53d8\u5f97\u5bb9\u6613\u7684\u547d\u4ee4\u3002\u63a5\u4e0b\u6765\u8ba9\u6211\u4eec\u770b\u770b\u90fd\u6709\u54ea\u4e9b\u5b8c\u6210\u5927\u5c0f\u5199\u8f6c\u6362\u7684\u547d\u4ee4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

tr \u547d\u4ee4<\/strong><\/div>\n

tr (translate) \u662f\u80fd\u8fd0\u7528\u5728\u547d\u4ee4\u884c\u6216\u8005\u811a\u672c\u4e0a\u7684\u6700\u7b80\u5355\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u547d\u4ee4\u4e4b\u4e00\u3002\u4f8b\u5982\u5982\u679c\u4f60\u60f3\u8981\u8ba9\u4e00\u4e32\u5b57\u7b26\u4e32\u5168\u90e8\u662f\u5927\u5199\u5b57\u6bcd\uff0c\u4f60\u53ef\u4ee5\u7528\u5982\u4e0b\u6240\u793a\u7684\u547d\u4ee4\u5b8c\u6210\u8fd9\u4e2a\u5185\u5bb9\uff1a<\/p>\n

$ echo hello alvin | tr [:lower:] [:upper:]\r\nHELLO ALVIN<\/pre>\n

\u4ee5\u4e0b\u4e3a\u8be5\u547d\u4ee4\u5e94\u7528\u5728\u811a\u672c\u4e0a\u7684\u4f8b\u5b50\uff0c\u5199\u5165\u6587\u4ef6depts\u7684\u5185\u5bb9\u5168\u4f1a\u662f\u5927\u5199\u7684\u683c\u5f0f\uff1a<\/p>\n

$ echo \"Enter department name: \" | tr [:lower:] [:upper:] >> depts<\/pre>\n

\u4e0a\u9762\u547d\u4ee4\u7684\u987a\u5e8f\u6362\u4e3a [:upper:] [:lower:] \u5c06\u4f1a\u5f97\u5230\u76f8\u53cd\u7684\u7ed3\u679c\uff0c\u6240\u6709\u8f93\u5165\u7684\u5b57\u6bcd\u90fd\u5c06\u53d8\u4e3a\u5c0f\u5199\u5b57\u6bcd\uff1a<\/p>\n

$ echo \"Enter department name: \" | tr [:upper:] [:lower:] >> depts<\/pre>\n

\u4f60\u53ef\u4ee5\u7528 A-Z a-z \u4ee3\u66ff [:upper:] [:lower:] \u6765\u8fbe\u5230\u76f8\u540c\u7684\u6548\u679c\uff1a<\/p>\n

$ echo \"Enter department name: \" | tr a-z A-Z >> depts<\/pre>\n
awk \u547d\u4ee4<\/strong><\/div>\n

awk \u547d\u4ee4\u7528 toupper \u548c tolower \u8fd9\u4e24\u4e2a\u9009\u9879\u5b8c\u6210\u5927\u5c0f\u5199\u8f6c\u6362\u3002\u4e0a\u6587\u6240\u8ff0\u7684\u5bf9\u811a\u672c\u8fdb\u884c\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u53ef\u4ee5\u7528\u8fd9\u4e2a\u547d\u4ee4\u4ee5\u5982\u4e0b\u7684\u65b9\u5f0f\u5b8c\u6210\uff1a<\/p>\n

$ echo \"Enter department name: \" | awk '{print toupper($0)}' >> depts<\/pre>\n

\u4ee5\u4e0a\u662f\u8f6c\u6362\u6210\u5927\u5199\u5b57\u6bcd\uff0c\u4e0b\u9762\u4e3a\u8f6c\u6362\u4e3a\u5c0f\u5199\u5b57\u6bcd\u7684\u65b9\u6cd5\uff1a<\/p>\n

$ echo \"Enter department name: \" | awk '{print tolower($0)}' >> depts<\/pre>\n
sed \u547d\u4ee4<\/strong><\/div>\n

sed \uff08stream editor\uff09 \u547d\u4ee4\u540c\u6837\u80fd\u591f\u5f88\u597d\u5b8c\u6210\u5927\u5c0f\u5199\u8f6c\u6362\u7684\u5de5\u4f5c\uff0c\u4e0b\u9762\u7684\u547d\u4ee4\u4e5f\u80fd\u591f\u8fbe\u5230\u524d\u9762\u4e24\u4e2a\u547d\u4ee4\u7684\u6548\u679c\uff1a<\/p>\n

$ echo \"Enter department name: \" | sed 's\/[a-z]\/\\U&\/g' >> depts<\/pre>\n

\u8981\u60f3\u5b8c\u6210\u76f8\u53cd\u7684\u8f6c\u6362\uff0c\u53ea\u9700\u628a\u4e0a\u9762\u90a3\u6761\u547d\u4ee4\u4e2d\u7684 U \u6362\u6210 L \u3001[a-z] \u6362\u6210 [A-Z] \u5373\u53ef\uff1a<\/p>\n

$ echo \"Enter department name: \" | sed 's\/[A-Z]\/\\L&\/g' >> depts<\/pre>\n

\u4fee\u6539\u6587\u4ef6\u91cc\u6587\u672c\u5185\u5bb9\u7684\u5927\u5c0f\u5199\u683c\u5f0f
\nawk \u548c sed \u547d\u4ee4\u90fd\u53ef\u4ee5\u5b8c\u6210\u5bf9\u6574\u4e2a\u6587\u6863\u5185\u5bb9\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u5de5\u4f5c\uff0c\u6240\u4ee5\u5982\u679c\u4f60\u9700\u8981\u628a\u6574\u4e2a\u6587\u6863\u5185\u5bb9\u8f6c\u6362\u6210\u5c0f\u5199\uff0c\u4f60\u53ef\u4ee5\u7528\u5982\u4e0b\u547d\u4ee4\u4ee5\u5c0f\u5199\u7684\u5f62\u5f0f\u8f93\u51fa\u67d0\u6587\u4ef6\u7684\u5185\u5bb9\u81f3\u5c4f\u5e55\u4e0a\uff1a<\/p>\n

$ awk '{print tolower($0)}' depts<\/pre>\n

\u5176\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n

enter department name:\r\nfinance\r\nbilling\r\nbookkeeping<\/pre>\n

\u6ce8\u610f\u6b64\u7ed3\u679c\u53ea\u662f\u5c06\u6253\u5370\u5728\u5c4f\u5e55\u7684\u5185\u5bb9\u8f6c\u6362\u4e3a\u4e86\u5c0f\u5199\uff0c\u672c\u8eab\u6587\u6863\u5185\u7684\u5927\u5199\u5b57\u6bcd\u5e76\u65e0\u53d8\u52a8\uff0c\u4f7f\u7528 cat depts \u547d\u4ee4\u67e5\u770b\u4fbf\u53ef\u77e5\u9053\u3002\u5982\u679c\u4f60\u60f3\u8981\u786e\u5b9e\u5730\u4fee\u6539\u6587\u6863\u5185\u5bb9\u7684\u5927\u5c0f\u5199\uff0c\u4f60\u53ef\u4ee5\u7528\u5982\u4e0b\u547d\u4ee4\u5b8c\u6210\uff1a<\/p>\n

$ awk '{print tolower($0)}' depts > depts-\r\n$ mv depts- depts<\/pre>\n

sed \u547d\u4ee4\u53ef\u4ee5\u5b8c\u6210\u548c awk \u76f8\u540c\u7684\u529f\u80fd\uff0c\u53ea\u662f\u7528\u6cd5\u4e0a\u7565\u6709\u4e0d\u540c\uff0c\u5176\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n

$ sed 's\/[A-Z]\/\\L&\/g' depts<\/pre>\n
\u53ea\u8ba9\u9996\u5b57\u6bcd\u5927\u5199<\/strong><\/div>\n

\u53ea\u8ba9\u4e00\u4e32\u5b57\u7b26\u4e32\u4e2d\u5404\u4e2a\u5355\u8bcd\u7684\u9996\u5b57\u6bcd\u5927\u5199\uff0c\u53ef\u4ee5\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u5b8c\u6210\uff1a<\/p>\n

$ echo design \\& engineering| sed -e \"s\/\\b\\(.\\)\/\\u\\1\/g\"\r\nDesign & Engineering<\/pre>\n

\u4e0a\u9762\u8fd9\u4e00\u6761\u547d\u4ee4\u53ef\u4ee5\u53ea\u8ba9\u9996\u5b57\u6bcd\u5927\u5199\u800c\u5176\u4ed6\u5b57\u6bcd\u4e0d\u53d8\u3002<\/p>\n

\u786e\u4fdd\u53ea\u6709\u9996\u5b57\u6bcd\u5927\u5199<\/strong><\/div>\n

\u5f53\u4f60\u9700\u8981\u5bf9\u4e00\u5927\u6279\u6587\u672c\u8fdb\u884c\u8fd9\u4e2a\u64cd\u4f5c\u7684\u65f6\u5019\uff0c\u6bd4\u5982\u8981\u4ee5\u6b63\u786e\u7684\u683c\u5f0f\u663e\u793a\u4e00\u5927\u6279\u4eba\u7684\u59d3\u540d\u65f6\uff0c\u9700\u8981\u505a\u7684\u4e8b\u60c5\u4f1a\u53d8\u5f97\u7a0d\u5fae\u96be\u4e00\u4e9b\u3002\u8fd9\u91cc\u63d0\u4f9b\u4e24\u79cd\u65b9\u6cd5\u5b8c\u6210\u8fd9\u4e2a\u4efb\u52a1\uff1a<\/p>\n

\u7528 sed \u547d\u4ee4\u5b8c\u6210<\/strong><\/div>\n

\u4e3a\u4e86\u786e\u4fdd\u7ed3\u679c\u6b63\u786e\uff0c\u9700\u8981\u66f4\u52a0\u590d\u6742\u7684 sed \u547d\u4ee4\u683c\u5f0f\uff1a<\/p>\n

$ echo design \\& ENGINEERING | sed 's\/\\b\\([[:alpha:]]\\)\\([[:alpha:]]*\\)\\b\/\\u\\1\\L\\2\/g'\r\nDesign & Engineering<\/pre>\n
\u7528 python \u4ee3\u7801\u5b8c\u6210<\/strong><\/div>\n

\u5982\u679c\u4f60\u7684 Linux \u4e0a\u5b89\u88c5\u4e86 python \uff0c\u4f60\u53ef\u4ee5\u7528\u5982\u4e0b\u7684\u547d\u4ee4\u5b8c\u6210\u5bf9\u6587\u672c\u7684\u9996\u5b57\u6bcd\u5927\u5199\u683c\u5f0f\u5316\uff0cpython \u4ee3\u7801\u6bd4\u4e0a\u6587\u7684 sed \u547d\u4ee4\u7684\u6b63\u5219\u5f0f\u8981\u5bb9\u6613\u7406\u89e3\u591a\u4e86\uff1a<\/p>\n

$ echo -n \"design & engineering\" | python3 -c \"import sys; print(sys.stdin.read().title())\"\r\nDesign & Engineering<\/pre>\n

Linux \u91cc\u9762\u6709\u8bb8\u591a\u7528\u4e8e\u5927\u5c0f\u5199\u8f6c\u6362\u7684\u547d\u4ee4\uff0c\u54ea\u4e00\u4e2a\u7528\u7740\u66f4\u597d\u53d6\u51b3\u4e8e\u4f60\u662f\u5904\u7406\u4e00\u4e32\u5b57\u7b26\u8fd8\u662f\u6574\u4e2a\u6587\u4ef6\u3002\u5e0c\u671b\u672c\u6587\u4ecb\u7ecd\u7684\u5404\u79cd\u547d\u4ee4\u80fd\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff0c\u5982\u679c\u4f60\u5bf9\u8fd9\u4e9b\u547d\u4ee4\u6709\u4ec0\u4e48\u7591\u95ee\uff0c\u6b22\u8fce\u7559\u8a00\u8ba8\u8bba\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"

tr (translate) \u662f\u80fd\u8fd0\u7528\u5728\u547d\u4ee4\u884c\u6216\u8005\u811a\u672c\u4e0a\u7684\u6700\u7b80\u5355\u7684\u5927\u5c0f\u5199\u8f6c\u6362\u547d\u4ee4\u4e4b\u4e00\u3002\u4f8b\u5982\u5982\u679c\u4f60\u60f3\u8981\u8ba9\u4e00\u4e32\u5b57\u7b26 […]<\/p>\n","protected":false},"author":1469,"featured_media":203300,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-203294","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/203294","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=203294"}],"version-history":[{"count":6,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/203294\/revisions"}],"predecessor-version":[{"id":203302,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/203294\/revisions\/203302"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/203300"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=203294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=203294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=203294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}