{"id":812,"date":"2019-01-25T20:41:54","date_gmt":"2019-01-25T20:41:54","guid":{"rendered":"https:\/\/www.science.smith.edu\/sawlab\/?page_id=812"},"modified":"2019-01-28T17:20:47","modified_gmt":"2019-01-28T17:20:47","slug":"command-line-tutorial_3","status":"publish","type":"page","link":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/","title":{"rendered":"Command Line Tutorial"},"content":{"rendered":"<p>So&#8230; now we have a folder full of fasta files.  Wouldn&#8217;t it be nice to know what is in them?  There are a couple of ways of exploring these files.  We will look at three &#8211; more, tail and grep.<\/p>\n<p>The more command is just a way to read through a readable file.  Go to your terminal (you should still be pointing into the Unix folder &#8211; if you aren&#8217;t, use what you know about cd to get back there.)  One of the fasta files we extracted from Archive.zip is KP760420.fasta.  In the terminal, type<\/p>\n<p><code>more KP760420.fasta<\/code><\/p>\n<p>This shows you the first few lines of text from any text file.  If the file is longer than a few lines, you can scroll through the entire file by hitting the space bar.  In the case of these fasta files, they are short enough that &#8216;more&#8217; shows the entire contents of the file.<\/p>\n<p>The tail command is similar, but shows only the last few lines of the file.  Try:<\/p>\n<p><code>tail KP760420.fasta<\/code><\/p>\n<p>In this case, you don&#8217;t see the first line of the file because the fasta file is longer than the number of lines <strong>tail<\/strong> returns.  You would normally use <strong>tail<\/strong> to look at the end of really long file &#8211; if you used <strong>more<\/strong> you would need to scroll through all the lines and if your file is thousands of lines long, that could take a while.<\/p>\n<p>If you want to search for a specific word or set of characters in a file, you can use grep.  Is the string &#8220;TGCCATATAAGGGACTGAA&#8221;  in the fasta file KP760420.fasta?  In the terminal type:<\/p>\n<p><code>grep TGCCATATAAGGGACTGAA KP760420.fasta<\/code><\/p>\n<p>If the search string is in the file, grep will return the line it is found in.  grep has an option <\/p>\n<p><strong>-c<\/strong> <\/p>\n<p>which will return the number of times a string is found in a file.  See how many times the sequence &#8216;TATA&#8217; is found in the sequence in KP760420.fasta.  <\/p>\n<p><code>grep -c TATA KP760420.fasta<\/code><\/p>\n<blockquote><p><ins datetime=\"2019-01-25T20:36:50+00:00\">How many times is &#8216;ATGC&#8217; in the sequence in KP760420.fasta?<\/ins><\/p><\/blockquote>\n<p>grep can also look in multiple files with one command.  Say we want to know which of the many fasta files we downloaded are sequences from Brugia. Unix uses * as a wildcard, and can be used as an argument.  This code:<\/p>\n<p>grep Brugia *<\/p>\n<p>asks the computer to look in every file in the folder it is pointing to, and say whether the word Brugia is found in it.  Give it a try now.<\/p>\n<blockquote><p><ins datetime=\"2019-01-25T20:39:42+00:00\">How many of the fasta files are from Brugia?  Which are they?<\/ins><\/p><\/blockquote>\n<blockquote><p><ins datetime=\"2019-01-25T20:39:42+00:00\">How would you use the -c option to find out how many times the string &#8220;ATGTG&#8221; is in each file?<\/ins><\/p><\/blockquote>\n<p><a href=\"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_4\/\">Next &#8230;<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>So&#8230; now we have a folder full of fasta files. Wouldn&#8217;t it be nice to know what is in them? There are a couple of ways of exploring these files. We will look at three &#8211; more, tail and grep. &hellip; <a href=\"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":73,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"class_list":["post-812","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Command Line Tutorial - The Williams Lab<\/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:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Command Line Tutorial - The Williams Lab\" \/>\n<meta property=\"og:description\" content=\"So&#8230; now we have a folder full of fasta files. Wouldn&#8217;t it be nice to know what is in them? There are a couple of ways of exploring these files. We will look at three &#8211; more, tail and grep. &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/\" \/>\n<meta property=\"og:site_name\" content=\"The Williams Lab\" \/>\n<meta property=\"article:modified_time\" content=\"2019-01-28T17:20:47+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/command-line-tutorial_3\\\/\",\"url\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/command-line-tutorial_3\\\/\",\"name\":\"Command Line Tutorial - The Williams Lab\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/#website\"},\"datePublished\":\"2019-01-25T20:41:54+00:00\",\"dateModified\":\"2019-01-28T17:20:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/command-line-tutorial_3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/command-line-tutorial_3\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/command-line-tutorial_3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Command Line Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/#website\",\"url\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/\",\"name\":\"The Williams Lab\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.science.smith.edu\\\/sawlab\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Command Line Tutorial - The Williams Lab","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:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/","og_locale":"en_US","og_type":"article","og_title":"Command Line Tutorial - The Williams Lab","og_description":"So&#8230; now we have a folder full of fasta files. Wouldn&#8217;t it be nice to know what is in them? There are a couple of ways of exploring these files. We will look at three &#8211; more, tail and grep. &hellip; Continue reading &rarr;","og_url":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/","og_site_name":"The Williams Lab","article_modified_time":"2019-01-28T17:20:47+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/","url":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/","name":"Command Line Tutorial - The Williams Lab","isPartOf":{"@id":"https:\/\/www.science.smith.edu\/sawlab\/#website"},"datePublished":"2019-01-25T20:41:54+00:00","dateModified":"2019-01-28T17:20:47+00:00","breadcrumb":{"@id":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.science.smith.edu\/sawlab\/command-line-tutorial_3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.science.smith.edu\/sawlab\/"},{"@type":"ListItem","position":2,"name":"Command Line Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.science.smith.edu\/sawlab\/#website","url":"https:\/\/www.science.smith.edu\/sawlab\/","name":"The Williams Lab","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.science.smith.edu\/sawlab\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/pages\/812","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/users\/73"}],"replies":[{"embeddable":true,"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/comments?post=812"}],"version-history":[{"count":7,"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/pages\/812\/revisions"}],"predecessor-version":[{"id":843,"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/pages\/812\/revisions\/843"}],"wp:attachment":[{"href":"https:\/\/www.science.smith.edu\/sawlab\/wp-json\/wp\/v2\/media?parent=812"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}