{"id":4192,"date":"2011-08-10T09:45:13","date_gmt":"2011-08-10T13:45:13","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=4192"},"modified":"2011-08-10T09:45:13","modified_gmt":"2011-08-10T13:45:13","slug":"glark","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/glark\/","title":{"rendered":"Glark"},"content":{"rendered":"<p>From <a href=http:\/\/www.linux.com\/learn\/tutorials\/480530:is-glark-a-better-grep target=\"_blank\" rel=\"noopener noreferrer\">Linux.com<\/a><br \/>\nBy <a href=\"https:\/\/github.com\/bilalq\/villustrator\" target=\"_blank\" rel=\"noopener noreferrer\">Joe &#8216;Zonker&#8217; Brockmeier<\/a><\/p>\n<p>GNU grep is one of my go-to tools on any Linux box. But grep isn&#8217;t the only tool in town. If you want to try something a bit different, check out glark a grep alternative that might might be better in some situations.<\/p>\n<p>What is glark? Basically, it&#8217;s a utility that&#8217;s similar to grep, but it has a few features that grep does not. This includes complex expressions, Perl-compatible regular expressions, and excluding binary files. It also makes showing contextual lines a bit easier. Let&#8217;s take a look.<\/p>\n<p>I installed glark (yes, annoyingly it&#8217;s yet another *nix utility that has no initial cap) on Linux Mint 11. Just grab it with apt-get install glark and you should be good to go. Simple searches work the same way as with grep: glark string filenames. So it&#8217;s pretty much a drop-in replacement for those. But you&#8217;re interested in what makes glark special. So let&#8217;s start with a complex expression, where you&#8217;re looking for this or that term:<\/p>\n<p><code>glark -r -o thing1 thing2 *<\/code><\/p>\n<p>This will search the current directory and subdirectories for &#8220;thing1&#8221; or &#8220;thing2.&#8221; When the results are returned, glark will colorize the results and each search term will be highlighted in a different color. So if you search for, say &#8220;Mozilla&#8221; and &#8220;Firefox,&#8221; you&#8217;ll see the terms in different colors. You can also use this to see if something matches within a few lines of another term. Here&#8217;s an example:<\/p>\n<p><code>glark --and=3 -o Mozilla Firefox -o ID LXDE *<\/code><\/p>\n<p>This was a search I was using in my directory of Linux.com stories that I&#8217;ve edited. I used three terms I knew were in one story, and one term I knew wouldn&#8217;t be. You can also just use the &#8211;and option to spot two terms within X number of lines of each other, like so:<\/p>\n<p><code>glark --and=3 term1 term2<\/code><\/p>\n<p>That way, both terms must be present. You&#8217;ll note the &#8211;and option is a bit simpler than grep&#8217;s context line options. However, glark tries to stay compatible with grep, so it also supports the -A, -B and -C options from grep. Miss the grep output format? You can tell glark to use grep format with the &#8211;grep option. Most, if not all, GNU grep options should work with glark.<\/p>\n<p><strong>Before and After<\/strong><\/p>\n<p>If you need to search through the beginning or end of a file, glark has the &#8211;before and &#8211;after options (short versions, -b and -a). You can use these as percentages or as absolute number of lines. For instance:<\/p>\n<p><code>glark -a 20 expression *<\/code><\/p>\n<p>That will find instances of expression after line 20 in a file.<\/p>\n<p><strong>The glark Configuration File<\/strong><\/p>\n<p>Note that you can have a ~\/.glarkrc that will set common options for each use of glark (unless overridden at the command line). The man page for glark does include some examples, like so:<\/p>\n<p><code><br \/>\nafter-context:     1<br \/>\nbefore-context:    6<br \/>\ncontext:           5<br \/>\nfile-color:        blue on yellow<br \/>\nhighlight:         off<br \/>\nignore-case:       false<br \/>\nquiet:             yes<br \/>\ntext-color:        bold reverse<br \/>\nline-number-color: bold<br \/>\nverbose:           false<br \/>\ngrep:              true<br \/>\n<\/code><\/p>\n<p>Just put that in your ~\/.glarkrc and customize it to your heart&#8217;s content. Note that I&#8217;ve set mine to grep: false and added the binary-files: without-match option. You&#8217;ll definitely want the quiet option to suppress all the notes about directories, etc. See the man page for more options. It&#8217;s probably a good idea to spend about 10 minutes on setting up a configuration file.<\/p>\n<p><strong>Final Thoughts<\/strong><\/p>\n<p>One thing that I have noticed is that glark doesn&#8217;t seem as fast as grep. When I do a recursive search through a bunch of directories containing (mostly) HTML files, I seem to get results a lot faster with grep. This is not terribly important for most of the stuff I do with either utility. However, if you&#8217;re doing something where performance is a major factor, then you may want to see if grep fits the bill better.<\/p>\n<p>Is glark &#8220;better&#8221; than grep? It depends entirely on what you&#8217;re doing. It has a few features that give it an edge over grep, and I think it&#8217;s very much worth trying out if you&#8217;ve never given it a shot.<\/p>\n<p>From <a href=http:\/\/www.linux.com\/learn\/tutorials\/480530:is-glark-a-better-grep target=\"_blank\" rel=\"noopener noreferrer\">Linux.com<\/a> <\/p>\n<p>One more thing, Glark can be installed on a Cent\/Redhat server using<br \/>\n<code>gem install glark<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From Linux.com By Joe &#8216;Zonker&#8217; Brockmeier GNU grep is one of my go-to tools on any Linux box. But grep isn&#8217;t the only tool in town. If you want to try something a bit different, check out glark a grep alternative that might might be better in some situations. What is glark? Basically, it&#8217;s a&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/glark\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-4192","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Glark - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/glark\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Glark - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"From Linux.com By Joe &#8216;Zonker&#8217; Brockmeier GNU grep is one of my go-to tools on any Linux box. But grep isn&#8217;t the only tool in town. If you want to try something a bit different, check out glark a grep alternative that might might be better in some situations. What is glark? Basically, it&#8217;s a... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/glark\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2011-08-10T13:45:13+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Glark\",\"datePublished\":\"2011-08-10T13:45:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/\"},\"wordCount\":680,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/\",\"name\":\"Glark - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2011-08-10T13:45:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/glark\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Glark\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Glark - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/glark\/","og_locale":"en_US","og_type":"article","og_title":"Glark - Linux Shtuff","og_description":"From Linux.com By Joe &#8216;Zonker&#8217; Brockmeier GNU grep is one of my go-to tools on any Linux box. But grep isn&#8217;t the only tool in town. If you want to try something a bit different, check out glark a grep alternative that might might be better in some situations. What is glark? Basically, it&#8217;s a... Read More","og_url":"https:\/\/g33kinfo.com\/info\/glark\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2011-08-10T13:45:13+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/glark\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/glark\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Glark","datePublished":"2011-08-10T13:45:13+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/glark\/"},"wordCount":680,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/glark\/","url":"https:\/\/g33kinfo.com\/info\/glark\/","name":"Glark - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2011-08-10T13:45:13+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/glark\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/glark\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/glark\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Glark"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/4192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=4192"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/4192\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=4192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=4192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=4192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}