{"id":131446,"date":"2019-01-03T10:44:16","date_gmt":"2019-01-03T02:44:16","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=131446"},"modified":"2018-12-27T09:45:24","modified_gmt":"2018-12-27T01:45:24","slug":"linux-study-comm","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-study-comm.html","title":{"rendered":"\u6df1\u5165\u6d45\u51fa\u5b66\u4e60linux\u57fa\u7840"},"content":{"rendered":"
\u4e00\u3001\u590d\u4e60\u5e38\u7528\u547d\u4ee4<\/strong><\/div>\n

\u547d\u4ee4cd\uff1a\u6253\u5f00\u6587\u4ef6\u5939
\n\u547d\u4ee4ls\uff1a\u67e5\u770b\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6
\n\u547d\u4ee4ls -l(\u7b80\u5199\u4e3all)\uff1a\u67e5\u770b\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u8be6\u7ec6\u4fe1\u606f
\n\u547d\u4ee4pwd\uff1a\u67e5\u770b\u5f53\u524d\u4f4d\u7f6e
\n\u547d\u4ee4mkdir\uff1a\u521b\u5efa\u6587\u4ef6\u5939\uff0c\u52a0\u53c2\u6570 -p \u53ef\u4ee5\u7ea7\u8054\u521b\u5efa\u6587\u4ef6\u5939\u3002
\n\u547d\u4ee4touch\uff1a\u521b\u5efa\u6587\u4ef6
\n\u547d\u4ee4vi\uff1a\u7f16\u8f91\u6587\u4ef6\uff08\u7c7b\u4f3c\u4e8e\u4f7f\u7528\u8bb0\u4e8b\u672c\u7f16\u8f91\u6587\u4ef6\uff09
\n\u547d\u4ee4vim\uff1a\u7f16\u8f91\u6587\u4ef6\uff08\u7c7b\u4f3c\u4e8e\u4f7f\u7528Word\u7f16\u8f91\u6587\u4ef6\uff09
\n\u547d\u4ee4>\uff1a\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9\uff0c\u5c06\u6b63\u786e\u7684\u91cd\u5b9a\u5411\u5185\u5bb9\u8ffd\u52a0\u5728\u6587\u4ef6\u7ed3\u5c3e
\n\u547d\u4ee4>>\uff1a\u4e0d\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9\uff0c\u5c06\u6b63\u786e\u7684\u5185\u5bb9\u8ffd\u52a0\u5728\u6587\u4ef6\u7ed3\u5c3e
\n\u547d\u4ee41>\uff1a\u7b49\u540c\u4e8e\u547d\u4ee4>
\n\u547d\u4ee41>>\uff1a\u7b49\u540c\u4e8e\u547d\u4ee4>>
\n\u547d\u4ee42>\uff1a\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9\uff0c\u5c06\u9519\u8bef\u7684\u91cd\u5b9a\u5411\u5185\u5bb9\u8ffd\u52a0\u5728\u6587\u4ef6\u7ed3\u5c3e
\n\u547d\u4ee42>>\uff1a\u4e0d\u6e05\u7a7a\u6587\u4ef6\u5185\u5bb9\uff0c\u5c06\u9519\u8bef\u7684\u91cd\u5b9a\u5411\u5185\u5bb9\u8ffd\u52a0\u5728\u6587\u4ef6\u7ed3\u5c3e<\/p>\n

\u4e8c\u3001\u590d\u5236\u4e0e\u5220\u9664<\/strong><\/div>\n

1\u3001\u590d\u5236\/\u5907\u4efd\u6587\u4ef6\u547d\u4ee4cp
\n\u4e00\u822c\u5728\u7f16\u8f91\u6587\u4ef6\u5185\u5bb9\u524d\uff0c\u90fd\u4f1a\u5c06\u6e90\u6587\u4ef6\u8fdb\u884c\u5907\u4efd\u64cd\u4f5c\u3002\u5907\u4efd\u540e\u7684\u6587\u4ef6\u5728\u6587\u4ef6\u540d\u540e+.bak\uff08\u7528\u4e8e\u533a\u5206\u6587\u4ef6\uff09<\/p>\n

[root@jsh-01 ~]# cd \/usr\/local\/src\/test\r\n[root@jsh-01 test]# ls\r\n1.txt\r\n[root@jsh-01 test]# cp 1.txt  1.txt.bak\r\n[root@jsh-01 test]# ls\r\n1.txt  1.txt.bak\r\n[root@jsh-01 test]# cp 1.txt \/usr\/local\/src\r\n[root@jsh-01 test]# ls \/usr\/local\/src\r\n1.txt  mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  test<\/pre>\n

2\u3001\u590d\u5236\u76ee\u5f55\u547d\u4ee4cp -r\uff1a\u590d\u5236\u76ee\u5f55\u53ca\u76ee\u5f55\u4e0b\u7684\u5185\u5bb9\u3002
\n3\u3001\u79fb\u52a8\u6587\u4ef6\u6216\u76ee\u5f55\uff0c\u547d\u4ee4mv
\n4\u3001\u5220\u9664\u6587\u4ef6\uff0c\u547d\u4ee4rm<\/p>\n

[root@jsh-01 test]# ls\r\n1.txt  1.txt.bak  1.txt.bak2  1.txt.bak3  1.txt.bak4\r\n[root@jsh-01 test]# rm 1.txt.bak4\r\nrm: remove regular file \u20181.txt.bak4\u2019? y\r\n[root@jsh-01 test]# ls\r\n1.txt  1.txt.bak  1.txt.bak2  1.txt.bak3<\/pre>\n

5\u3001\u5220\u9664\u76ee\u5f55\uff0c\u547d\u4ee4rm -r\uff08\u5982\u679c\u76ee\u5f55\u4e0d\u4e3a\u7a7a\uff0c\u5219\u4f1a\u63d0\u793a\u662f\u5426\u5220\u9664\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3002\uff09
\n6\u3001\u5f3a\u5236\u5220\u9664\u76ee\u5f55\uff0c\u547d\u4ee4 rm -rf\uff08\u4e0d\u8bba\u76ee\u5f55\u662f\u5426\u4e3a\u7a7a\uff0c\u90fd\u4f1a\u5f3a\u5236\u5220\u9664\uff09<\/p>\n

[root@jsh-01 src]# ls\r\n1.txt  mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  test\r\n[root@jsh-01 src]# cp test test.bak\r\ncp: omitting directory \u2018test\u2019\r\n[root@jsh-01 src]# cp -r test test.bak\r\n[root@jsh-01 src]# ls\r\n1.txt  mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  test  test.bak\r\n[root@jsh-01 src]# rm -r test.bak\r\nrm: descend into directory \u2018test.bak\u2019? n\r\n[root@jsh-01 src]# rm -r test.bak\r\nrm: descend into directory \u2018test.bak\u2019? y\r\nrm: remove regular file \u2018test.bak\/1.txt.bak\u2019? y\r\nrm: remove regular file \u2018test.bak\/1.txt\u2019? n\r\nrm: remove directory \u2018test.bak\u2019? n\r\n[root@jsh-01 src]# ls\r\n1.txt  mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  test  test.bak\r\n[root@jsh-01 src]# ls test.bak\/\r\n1.txt\r\n[root@jsh-01 src]# rm -rf test.bak\r\n[root@jsh-01 src]# ls\r\n1.txt  mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz  test\r\n<\/pre>\n
\u4e09\u3001fine\u547d\u4ee4\uff1a\u67e5\u627e<\/strong><\/div>\n

\u4e00\u822c\u5728\u5220\u9664\u6587\u4ef6\u4e4b\u524d\u5148\u7cbe\u51c6\u67e5\u627e\uff0c\u907f\u514d\u8bef\u5220\u3002
\n\u547d\u4ee4\u683c\u5f0f\uff1afind \u8def\u5f84\uff08\u5728\u54ea\u91cc\u627e\uff09 -type f -name \"1.txt\"
\n\u5176\u4e2d-type \u6307\u7684\u662f\u67e5\u627e\u7684\u7c7b\u578b\u3002\u5e38\u7528\u7684\u53c2\u6570\u6709f \u548cd\u3002f \u5373file \u6587\u4ef6\uff1bd \u5373directory \u76ee\u5f55\u3002<\/p>\n

[root@jsh-01 ~]# ll \/usr\/local\/src\r\ntotal 308920\r\n-rw-r--r-- 1 root root        60 Dec 17 21:30 1.txt\r\n-rw-r--r-- 1 root root 316320366 Nov 25 19:39 mysql-5.6.36-linux-glibc2.5-x86_64.tar.gz\r\ndrwxr-xr-x 2 root root      4096 Dec 17 22:02 test\r\n[root@jsh-01 ~]# find \/usr\/ -type f -name \"1.txt\"\r\n\/usr\/local\/src\/test\/1.txt\r\n\/usr\/local\/src\/1.txt\r\n[root@jsh-01 ~]# find \/usr\/ -type f -name '1.txt'\r\n\/usr\/local\/src\/test\/1.txt\r\n\/usr\/local\/src\/1.txt\r\n[root@jsh-01 ~]# find \/usr\/ -type f -name 1.txt\r\n\/usr\/local\/src\/test\/1.txt\r\n\/usr\/local\/src\/1.txt\r\n<\/pre>\n
\u56db\u3001\u7ba1\u9053\u7b26 \u201c|\u201d<\/strong><\/div>\n

\u4e00\u822c\u7ba1\u9053\u7b26\u540e\u9762\u4f1a\u7d27\u8ddf xargs \u547d\u4ee4\uff0c\u7528\u4e8e\u5c06\u7ba1\u9053\u7b26\u524d\u9762\u7684\u8f93\u51fa\u7ed3\u679c\u8f6c\u6362\u4e3a\u547d\u4ee4\u884c\u3002
\n\u7ba1\u9053\u7b26\u4f5c\u7528\uff1a\u5c06\u7ba1\u9053\u7b26\u524d\u9762\u547d\u4ee4\u7684\u7ed3\u679c\u4f20\u9012\u7ed9\u540e\u9762\u7684\u547d\u4ee4\u3002<\/p>\n

[root@jsh-01 ~]# echo 123456789 > \/usr\/local\/src\/1.txt \r\n[root@jsh-01 ~]# echo 666666666 > \/usr\/local\/src\/test\/1.txt \r\n[root@jsh-01 ~]# find \/usr\/local\/src\/ -type f -name 1.txt |xargs cat\r\n666666666\r\n123456789\r\n[root@jsh-01 ~]# find \/usr\/ -type f -name 1.txt |xargs ls -l\r\n-rw-r--r-- 1 root root 10 Dec 20 20:37 \/usr\/local\/src\/1.txt\r\n-rw-r--r-- 1 root root 10 Dec 20 20:38 \/usr\/local\/src\/test\/1.txt<\/pre>\n
\u4e94\u3001\u8fc7\u6ee4\u547d\u4ee4 grep<\/strong><\/div>\n

\u5728\u6587\u4ef6\u4e2d\u627e\u5230\uff08\u8fc7\u6ee4\uff09\u4f60\u60f3\u8981\u7684\u5185\u5bb9\u5e76\u8f93\u51fa\u3002\u4f8b\u5982\uff1agrep \"666\" 1.txt<\/p>\n

grep -v \u6392\u9664\u3002\u5728\u6587\u4ef6\u4e2d\u627e\u5230\u4f60\u8981\u6392\u9664\u7684\u5185\u5bb9\uff0c\u663e\u793a\u6392\u9664\u540e\u7684\u5185\u5bb9\u3002<\/p>\n

[root@jsh-01 test]# cat 1.txt\r\n666666666\r\n[root@jsh-01 test]# grep \"5\" 1.txt\r\n[root@jsh-01 test]# grep -v \"5\" 1.txt\r\n666666666<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u547d\u4ee4cd\uff1a\u6253\u5f00\u6587\u4ef6\u5939 \u547d\u4ee4ls\uff1a\u67e5\u770b\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6 \u547d\u4ee4ls -l(\u7b80\u5199\u4e3all)\uff1a\u67e5\u770b\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u8be6\u7ec6\u4fe1\u606f \u547d\u4ee4 […]<\/p>\n","protected":false},"author":63,"featured_media":132076,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-131446","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\/131446","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\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=131446"}],"version-history":[{"count":5,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/131446\/revisions"}],"predecessor-version":[{"id":132121,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/131446\/revisions\/132121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/132076"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=131446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=131446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=131446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}