{"id":17,"date":"2008-05-30T13:45:32","date_gmt":"2008-05-30T09:45:32","guid":{"rendered":"http:\/\/www.unixpin.com\/wordpress\/?p=17"},"modified":"2008-10-29T14:18:10","modified_gmt":"2008-10-29T10:18:10","slug":"usefull-script-grep","status":"publish","type":"post","link":"https:\/\/www.unixpin.com\/?p=17","title":{"rendered":"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c grep"},"content":{"rendered":"<p>\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<p>\u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u043e\u0434\u0435\u0436\u0438\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 grep -l, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0439\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 &#171;10.1.2.3&#187; \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/etc :<\/p>\n<pre># grep -l 10.1.2.3 \/etc\/*<\/pre>\n<p>\u041f\u043e\u0438\u0441\u043a \u043f\u043e <a href=\"https:\/\/www.unixpin.com\/2008\/10\/29\/regex-unix\/\" target=\"_blank\">\u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e<\/a> \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 egrep. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u0439\u0442\u0438, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440 (\u043e\u043f\u0446\u0438\u044f -i)\u00a0\u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ls\u00a0 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 &#8216;t&#8217; \u0438\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 &#8216;Ze&#8217;:<\/p>\n<pre># ls | egrep -i '^t|Ze'\r\ngconfd-zenoss\r\nmapping-zenoss\r\norbit-zenoss\r\ntrtmpP6aOeP\r\ntrtmpZ6aWeP<\/pre>\n<p>\u041d\u0430\u0439\u0442\u0438 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445 \/etc\/pa* \u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 ROT \u0438\u043b\u0438 ROOT, \u0438\u043b\u0438 ROOOT \u0438\u0442\u0434, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044e\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440:<\/p>\n<pre># egrep -li '^RO+T' \/etc\/pa*\r\n\/etc\/passwd<\/pre>\n<p>\u041f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u0443\u0441\u0442\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre># cat \/tmp\/file.txt | grep -v ^$\r\n# cat \/tmp\/file.txt | grep -v .<\/pre>\n<p>\u0421\u043c\u043e\u0442\u0440\u0438 \u0442\u0430\u043a\u0436\u0435 <a href=\"https:\/\/www.unixpin.com\/2008\/10\/29\/regex-unix\/\">\u0420\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0432 unix<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0447\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430: \u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u043e\u0434\u0435\u0436\u0438\u043c\u043e\u043c\u0443 \u0444\u0430\u0439\u043b\u043e\u0432 grep -l, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430\u0439\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0443 &#171;10.1.2.3&#187; \u0432\u043e \u0432\u0441\u0435\u0445 \u0444\u0430\u0439\u043b\u0430\u0445 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/etc : # grep -l 10.1.2.3 \/etc\/* \u041f\u043e\u0438\u0441\u043a \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c\u0443 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 egrep. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440: \u043d\u0430\u0439\u0442\u0438, \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440 (\u043e\u043f\u0446\u0438\u044f -i)\u00a0\u0432 \u0432\u044b\u0432\u043e\u0434\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b ls\u00a0 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u0441 &#8216;t&#8217; \u0438\u043b\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 &#8216;Ze&#8217;: # ls | egrep [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,24,25,4,93],"tags":[45,34,28,36,27],"class_list":["post-17","post","type-post","status-publish","format-standard","hentry","category-shell","category-hpux","category-linux","category-solaris","category-unix-tru64","tag-grep","tag-hp-ux","tag-programming-shell","tag-unix-linux","tag-unix-solaris"],"_links":{"self":[{"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/posts\/17","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17"}],"version-history":[{"count":4,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=\/wp\/v2\/posts\/17\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/www.unixpin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unixpin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}