{"id":1788,"date":"2019-10-10T17:25:03","date_gmt":"2019-10-10T15:25:03","guid":{"rendered":"https:\/\/betterqa.co\/?p=1788"},"modified":"2026-02-04T11:10:04","modified_gmt":"2026-02-04T09:10:04","slug":"file-searching-in-the-terminal","status":"publish","type":"post","link":"https:\/\/betterqa.co\/file-searching-in-the-terminal\/","title":{"rendered":"File Searching in the Terminal"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"1788\" class=\"elementor elementor-1788\" data-elementor-post-type=\"post\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-71c2202f elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"71c2202f\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-5825c946\" data-id=\"5825c946\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-22927266 elementor-widget elementor-widget-text-editor\" data-id=\"22927266\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\n<p class=\"wp-block-paragraph\">Finding the right information on time can be challenging when working with large files in the terminal. Especially log files, which contain lots of details about the activity of a system.\u00a0<\/p>\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"683\" class=\"wp-image-3866\" title=\"postare11\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-1024x683.png\" alt=\"file searching in the terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-1024x683.png 1024w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-300x200.png 300w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-768x512.png 768w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-1536x1024.png 1536w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-800x533.png 800w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-600x400.png 600w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11-345x230.png 345w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/postare11.png 1620w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n<p class=\"wp-block-paragraph\">\u00a0<\/p>\n<div class=\"bqa-sources\">\n  <h3>Sources<\/h3>\n  <ol>\n    <li><a href=\"https:\/\/www.gnu.org\/software\/grep\/manual\/grep.html\" rel=\"noopener nofollow\" target=\"_blank\">GNU Grep Manual<\/a><\/li>\n    <li><a href=\"https:\/\/www.gnu.org\/software\/findutils\/manual\/html_mono\/find.html\" rel=\"noopener nofollow\" target=\"_blank\">GNU Find Manual<\/a><\/li>\n    <li><a href=\"https:\/\/github.com\/BurntSushi\/ripgrep\" rel=\"noopener nofollow\" target=\"_blank\">Ripgrep Documentation<\/a><\/li>\n  <\/ol>\n<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a8d6c03 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"a8d6c03\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-461c23e\" data-id=\"461c23e\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-59859f2 elementor-widget elementor-widget-text-editor\" data-id=\"59859f2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Luckily, there are also lots of file-searching tools to cut through unnecessary info and get only the data that interests you.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>We&#8217;ll make a quick dive into some of the most basic file-reading tools that we use on a daily basis when handling log files.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><strong><em>Note<\/em><\/strong>: the commands have a fragment from their man description added beside them. If you don&#8217;t know what man is, try the man command in the terminal to find out.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-0c46d42 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"0c46d42\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a95ceae\" data-id=\"a95ceae\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3411867 elementor-widget elementor-widget-heading\" data-id=\"3411867\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">File Searching in the Terminal<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-035b2cc elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"035b2cc\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-81002ba\" data-id=\"81002ba\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7df3087 elementor-widget elementor-widget-heading\" data-id=\"7df3087\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">cat<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-69ab950 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"69ab950\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-720c9cd\" data-id=\"720c9cd\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-cf5ddf1 elementor-widget elementor-widget-text-editor\" data-id=\"cf5ddf1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><!-- \/wp:paragraph --><!-- wp:heading --><\/p>\n<p><!-- \/wp:heading --><!-- wp:heading --><\/p>\n<p>\u00a0The most basic command for reading a file from the terminal. It reads files sequentially, writing them to the standard output.<\/p>\n<p><!-- \/wp:heading --><!-- wp:paragraph --><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>As with most built-in Linux commands, it has several flags that can enhance its functionality. However, it&#8217;s frequently used without any of them to display the entire content of a file. Here&#8217;s an example:<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><br \/><img decoding=\"async\" width=\"250\" height=\"194\" class=\"wp-image-1790\" style=\"width: 250px;\" title=\"pic1 - cat\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic1-cat.png\" alt=\"Category File Searching In The Terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic1-cat.png 743w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic1-cat-300x233.png 300w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><br \/>It\u00a0<em>only<\/em>\u00a0displays the contents of sample.txt to the standard output. By using it in combination with the pipe &#8220;|&#8221; operator, it can deliver this output to other terminal commands instead of the standard output.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:heading --><\/p>\n<p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-4e80010 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"4e80010\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-23abc7a\" data-id=\"23abc7a\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-d4bb946 elementor-widget elementor-widget-heading\" data-id=\"d4bb946\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">pipe\u00a0'|'\u00a0\u00a0<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b74944b elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"b74944b\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2be6f72\" data-id=\"2be6f72\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-1f4a4f6 elementor-widget elementor-widget-text-editor\" data-id=\"1f4a4f6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><!-- \/wp:heading --><!-- wp:paragraph --><\/p>\n<p>&#8220;The pipe(8) daemon processes requests from the Postfix queue manager to deliver messages to external commands.&#8221;<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>The pipe operator is used between two commands. As an operator, its function is to pass the first command&#8217;s output to the second command&#8217;s input. Here&#8217;s an example:<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><br \/><img decoding=\"async\" width=\"250\" height=\"182\" class=\"wp-image-1793\" style=\"width: 250px;\" title=\"pic2 - tail\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic2-pipe.png\" alt=\"Tail File Searching In The Terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic2-pipe.png 910w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic2-pipe-300x219.png 300w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic2-pipe-768x560.png 768w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic2-pipe-271x198.png 271w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>The pipe operator already comes in handy and lets us filter the\u00a0<em>sample1.txt<\/em>. In the first example, it&#8217;s combined with the head to display the first line from sample1.txt. The second example it&#8217;s self-explanatory, but you should try it out anyway.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:heading --><\/p>\n<p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-c9bb7d6 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"c9bb7d6\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a4d54e8\" data-id=\"a4d54e8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-7fa48c7 elementor-widget elementor-widget-heading\" data-id=\"7fa48c7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">tail\u00a0<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-ba4e828 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"ba4e828\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-8320747\" data-id=\"8320747\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-a2acd91 elementor-widget elementor-widget-text-editor\" data-id=\"a2acd91\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><!-- \/wp:heading --><!-- wp:paragraph --><\/p>\n<p>&#8220;The tail utility displays the contents of file or, by default, its standard input, to the standard output.&#8221;<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>As you saw in the example above,\u00a0<em>tail<\/em>\u00a0can be used to display lines of text from a file, starting from the end of the file upwards.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>In combination with the\u00a0<strong>-f\u00a0<\/strong>flag,\u00a0<em>tail<\/em>\u00a0can constantly display in the terminal the lines of text that are appended to a file. This is a normal log file behavior; information is constantly added as new events happen in the system. Here&#8217;s an example of\u00a0<em>tail<\/em>\u00a0<em>-f<\/em>\u00a0:<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph {\"style\":{\"color\":{\"text\":\"#000000\"}}} --><\/p>\n<p class=\"has-text-color\" style=\"color: #000000;\"><br \/><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"149\" class=\"wp-image-1796\" style=\"width: 250px;\" title=\"pic4 - tail\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic4-tail.png\" alt=\"File Searching In The Terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic4-tail.png 1213w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic4-tail-300x179.png 300w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic4-tail-768x457.png 768w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic4-tail-1024x610.png 1024w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>So tail displayed the last 10 lines from sample.log and now waits to display the next lines of text that will be appended.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:heading --><\/p>\n<p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-19890d2 elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"19890d2\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a1848d8\" data-id=\"a1848d8\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-9f35958 elementor-widget elementor-widget-heading\" data-id=\"9f35958\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">grep\u00a0<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-a5950cc elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"a5950cc\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-e775044\" data-id=\"e775044\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f3d80b8 elementor-widget elementor-widget-text-editor\" data-id=\"f3d80b8\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><!-- \/wp:heading --><!-- wp:paragraph --><\/p>\n<p>&#8220;The grep utility searches any given input files, selecting lines that match one or more patterns.&#8221;<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Grep is a powerful and easy-to-use tool for finding the right information inside a given context. The context can be one or more files, and the correct information can be one or more patterns that interest you. Here&#8217;s an example:<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>In this example, I used grep to search for all the contexts in\u00a0<em>sample.log<\/em>\u00a0that contain the &#8216;<em>EVENT<\/em>&#8216; pattern. The response was very fast in this case, where the file had about 360 lines of text.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>You can check how many lines a file has by using\u00a0<strong>cat -n.<\/strong>\u00a0See how fast a command&#8217;s response is by typing\u00a0<em>time<\/em>\u00a0in front of it and then executing it.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>You can also check this simple explanation of the log entry levels (e.g., EVENT) and what they mean\u00a0<a href=\"https:\/\/www.tutorialspoint.com\/log4j\/log4j_logging_levels.htm\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">here<\/a>.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Tail and grep are the most useful command combinations when working with log <strong>files<\/strong>.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Let&#8217;s say you monitor the actions related to a specific ID. The logs can have dense information, so you only want those actions displayed and the rest ignored. The following command will do precisely that:\u00a0<strong>tail -1f file_name | grep &#8217;42&#8217;<\/strong><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>It will display the last line from\u00a0<em>file_name<\/em>\u00a0if &#8217;42&#8217; is present and any other lines (when appended) where &#8217;42&#8217; is found.\u00a0<em>Tail<\/em>\u00a0will run until you interrupt its execution.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>To search for a pattern in multiple files, you can type:\u00a0<strong>grep &#8217;42&#8217; file1 file2<\/strong><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>To search a file for multiple patterns, type:\u00a0<strong>grep -e &#8217;42&#8217; -e &#8217;43&#8217; file1<\/strong><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>This option is most useful when multiple -e options are used to specify multiple patterns.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><br \/><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"150\" class=\"wp-image-1795\" style=\"width: 250px;\" title=\"pic5 - grep files\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic5-grep-files.png\" alt=\"Grep Files In The Terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic5-grep-files.png 1209w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic5-grep-files-300x180.png 300w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic5-grep-files-768x461.png 768w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic5-grep-files-1024x614.png 1024w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><strong>-A,-B, -C flags<\/strong><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Other useful flags for grep are\u00a0<strong>-A<\/strong>\u00a0and\u00a0<strong>-B<\/strong>. They specify a context to be printed (B) before or (A) after the line that contains the pattern is displayed. You can also use the\u00a0<strong>-C\u00a0<\/strong>flag, which combines both\u00a0<em>-A<\/em>\u00a0and\u00a0<em>-B<\/em>\u00a0flags.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph {\"style\":{\"color\":{\"text\":\"#000000\"}}} --><\/p>\n<p class=\"has-text-color\" style=\"color: #000000;\"><br \/><img loading=\"lazy\" decoding=\"async\" width=\"250\" height=\"149\" class=\"wp-image-1794\" style=\"width: 250px;\" title=\"pic6 - grep flags\" src=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic6-grep-flags.png\" alt=\"Grep Flags In The Terminal\" srcset=\"https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic6-grep-flags.png 1207w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic6-grep-flags-300x179.png 300w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic6-grep-flags-768x458.png 768w, https:\/\/betterqa.co\/wp-content\/uploads\/2019\/10\/pic6-grep-flags-1024x611.png 1024w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Many command combinations can be done only with the commands mentioned above, especially with the help of pipe.\u00a0<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Feel free to try them and see how it goes.<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p>Extra: If you&#8217;re on MAC OS, try the following command &#8211;\u00a0<em>say<\/em>\u00a0hello world<\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\n<p><!-- \/wp:paragraph --><!-- wp:paragraph --><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-bc5e37b elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"bc5e37b\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a77c200\" data-id=\"a77c200\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3ac768f elementor-widget-divider--view-line elementor-widget elementor-widget-global elementor-global-5706 elementor-widget-divider\" data-id=\"3ac768f\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-divider\">\n\t\t\t<span class=\"elementor-divider-separator\">\n\t\t\t\t\t\t<\/span>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-717bb71 elementor-widget-tablet__width-initial elementor-widget elementor-widget-global elementor-global-5702 elementor-widget-text-editor\" data-id=\"717bb71\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p><strong>Stay Updated with the Latest in QA<\/strong><\/p>\n<p>The world of software testing and quality assurance is ever-evolving. To stay abreast of the latest methodologies, tools, and best practices, bookmark our blog. We\u2019re committed to providing in-depth insights, expert opinions, and trend analysis that can help you refine your software quality processes.<\/p>\n<p><a href=\"https:\/\/betterqa.co\/blog\/\" target=\"_new\">Visit our Blog<\/a><\/p>\n<p>Delve deeper into a range of specialized services we offer, tailored to meet the diverse needs of modern businesses. As well, hear what our clients have to say about us on <a href=\"https:\/\/clutch.co\/profile\/betterqa\" rel=\"nofollow noopener\" target=\"_blank\">Clutch!<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-251c437 elementor-align-left elementor-widget elementor-widget-global elementor-global-5701 elementor-widget-button\" data-id=\"251c437\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"button.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<div class=\"elementor-button-wrapper\">\n\t\t\t\t\t<a class=\"elementor-button elementor-button-link elementor-size-sm elementor-animation-grow\" href=\"https:\/\/betterqa.co\/software-testing-services\/#\">\n\t\t\t\t\t\t<span class=\"elementor-button-content-wrapper\">\n\t\t\t\t\t\t<span class=\"elementor-button-icon\">\n\t\t\t\t<svg aria-hidden=\"true\" class=\"e-font-icon-svg e-far-arrow-alt-circle-left\" viewBox=\"0 0 512 512\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M8 256c0 137 111 248 248 248s248-111 248-248S393 8 256 8 8 119 8 256zm448 0c0 110.5-89.5 200-200 200S56 366.5 56 256 145.5 56 256 56s200 89.5 200 200zm-72-20v40c0 6.6-5.4 12-12 12H256v67c0 10.7-12.9 16-20.5 8.5l-99-99c-4.7-4.7-4.7-12.3 0-17l99-99c7.6-7.6 20.5-2.2 20.5 8.5v67h116c6.6 0 12 5.4 12 12z\"><\/path><\/svg>\t\t\t<\/span>\n\t\t\t\t\t\t\t\t\t<span class=\"elementor-button-text\">See the other Services we provide<\/span>\n\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>File searching in the terminal for QA engineers. Command line tools that speed up debugging and testing.<\/p>\n","protected":false},"author":1,"featured_media":3866,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1016],"tags":[813,749,811,816,760,812,814,757,755,742,758,89,754,741,761],"class_list":["post-1788","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guides-and-tutorials","tag-cat","tag-code","tag-filesearching","tag-grep","tag-independentteam","tag-logfiles","tag-pipe","tag-qatesters","tag-qatesting","tag-softwaretesting","tag-softwareengineers","tag-terminal-searching","tag-testers","tag-testing","tag-thirdparty"],"acf":[],"_links":{"self":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts\/1788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/comments?post=1788"}],"version-history":[{"count":0,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/posts\/1788\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/media\/3866"}],"wp:attachment":[{"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/media?parent=1788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/categories?post=1788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/betterqa.co\/wp-json\/wp\/v2\/tags?post=1788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}