{"id":224,"date":"2012-06-12T11:57:54","date_gmt":"2012-06-12T03:57:54","guid":{"rendered":"http:\/\/rmohan.com\/?p=224"},"modified":"2012-06-12T11:57:54","modified_gmt":"2012-06-12T03:57:54","slug":"grep-command","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=224","title":{"rendered":"Grep Command"},"content":{"rendered":"<p><strong>Grep Command <\/strong><\/p>\n<p>some examples of grep command:<\/p>\n<p>* Print Apache\u2019s documentroot directory name:<\/p>\n<p>$ grep -i documentroot  \/etc\/httpd\/conf\/httpd.conf<\/p>\n<p>* View file contents without comments and empty lines:<\/p>\n<p>$ grep -Ev \u201c^$|^#\u201d \/etc\/my.cnf<\/p>\n<p>* print only IP address assigned to the interface:<\/p>\n<p>$ ifconfig eth0 | grep &#8216;inet addr:&#8217; | cut -d&#8217;:&#8217; -f2 | awk &#8216;{ print $1}&#8217;<\/p>\n<p>* How many email messages sent for a particular date:<\/p>\n<p>$ cat \/var\/log\/maillog | grep &#8220;status=sent&#8221; | grep &#8220;May 25&#8221; | wc -l<\/p>\n<p>* Find out a running process\/daemon from process list (thanks to staranneph for recalling this):<\/p>\n<p>ps -ef | grep mysql<\/p>\n<p>* You can also note cpu\/mem usage by using above. like in below command output, you can see that Plesk\u2019s statistics process is utilizing more than 18% cpu alone:<\/p>\n<p>[root@myserver ~]# ps aux | grep statistics<br \/>\nroot      8183 18.4  0.0  58384  2848 ?        D    04:05   3:00 \/usr\/l<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Grep Command <\/p>\n<p>some examples of grep command:<\/p>\n<p>* Print Apache\u2019s documentroot directory name:<\/p>\n<p>$ grep -i documentroot \/etc\/httpd\/conf\/httpd.conf<\/p>\n<p>* View file contents without comments and empty lines:<\/p>\n<p>$ grep -Ev \u201c^$|^#\u201d \/etc\/my.cnf<\/p>\n<p>* print only IP address assigned to the interface:<\/p>\n<p>$ ifconfig eth0 | grep &#8216;inet addr:&#8217; | cut -d&#8217;:&#8217; -f2 | awk [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/224"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=224"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/224\/revisions"}],"predecessor-version":[{"id":225,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/224\/revisions\/225"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}