{"id":4732,"date":"2014-06-29T19:30:33","date_gmt":"2014-06-29T19:30:33","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=4732"},"modified":"2014-06-29T19:49:19","modified_gmt":"2014-06-29T19:49:19","slug":"perl-programming-using-the-terminal-in-linux-or-mac","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/perl-programming-using-the-terminal-in-linux-or-mac\/","title":{"rendered":"Perl programming:  using the terminal in Linux (or Mac?)"},"content":{"rendered":"<h1>Pursuing summer tutoring, we have embarked upon the PERL programming journey.\u00a0 The tutor continues it:\u00a0 soon, there might be no turning back.<\/h1>\n<p>In my <a href=\"?p=4699\">previous article<\/a>, I described how you might, in Windows, create a text file, save it, then find it in the terminal. Now, I&#8217;ll describe the corresponding procedure in Linux &#8211; which I believe will be the same for the Mac. Once again: I don&#8217;t have a Mac, so I can&#8217;t be sure. It&#8217;s my impression, however, that Linux and Mac, for this purpose, are similar.<\/p>\n<p>First, to create the file, you&#8217;ll open the text editor. In my flavour of Linux, it&#8217;s called &#8220;text editor&#8221;. You might write down a grocery list or colour choices for your paint:<\/p>\n<p>maroon, cappuccino, red granite, basalt<\/p>\n<p>Now, you&#8217;ll save that file. For convenience, you might create a new folder for PERL activities, then save the file in there. Perhaps you create the folder<br \/>\n&#8220;My_ perl_programs&#8221;.  (Unlike with Windows, the Linux terminal may not tolerate spaces in names).  Maybe you save the file as <span style=\"font-family: monospace;\">colours.txt<\/span> in your &#8220;My_perl_programs&#8221; folder.<\/p>\n<p>Now, you open the terminal &#8211; which, in my flavour of Linux, is called &#8220;terminal&#8221;. It&#8217;s in with the apps.<\/p>\n<p>When I open the terminal, it puts me in what I&#8217;d call my &#8220;home&#8221; directory. To see the contents of the directory, I enter the command<\/p>\n<p><span style=\"font-family: monospace;\">ls<\/span><\/p>\n<p>On my Linux terminal, <span style=\"font-family: monospace;\">ls<\/span> displays the directories in blue, while the files are in white. From the terminal&#8217;s point of view, a folder is a directory. You (hopefully) see &#8220;My_perl_programs&#8221; &#8211; or whatever you called your PERL folder &#8211; among the items listed by the <span style=\"font-family: monospace;\">ls<\/span> command. Maybe it&#8217;s even in blue.<\/p>\n<p>Let&#8217;s assume you did call your PERL programs directory &#8220;My_perl_programs&#8221;. To go into it now, enter the command<\/p>\n<p><span style=\"font-family: monospace;\">cd My_perl_programs<\/span><\/p>\n<p>Now, when you enter <span style=\"font-family:monospace\">ls<\/span>, you should see your text file <span style=\"font-family: monospace;\">colours.txt<\/span> &#8211; or whatever you called it &#8211; listed. If you do see it, you have successfully created a text file, then found it in the terminal &#8211; which is, after all, the point of this article.<\/p>\n<h4>\u00a0Three observations:<\/h4>\n<ol>\n<li>In Linux, the terminal doesn&#8217;t seem to tolerate names with spaces in between.\u00a0 Windows users will notice this difference.<\/li>\n<li>The Linux terminal is case sensitive, whereas the Windows one is not.\u00a0 Therefore, in Windows you can go into the &#8220;MeandMyself&#8221; directory using the command<br \/>\n<span style=\"font-family:monospace\">cd meandmyself<\/span>, while in Linux, you can&#8217;t.  You&#8217;d instead need to enter, literally, <span style=\"font-family:monospace\">cd MeandMyself<\/span>.<\/li>\n<li>In my Linux terminal, the <span style=\"font-family:monospace\">dir<\/span> command also works to list the contents of a directory, even though it&#8217;s the Windows command.  However, you might not get the colour coding you might (in Linux) get using the Linux command <span style=\"font-family:monospace\">ls<\/span>.\n<\/ol>\n<p>To my knowledge, the Mac procedure for accomplishing the tasks above is very similar &#8211; if not virtually the same.  Perhaps now &#8220;everyone&#8221; knows how to create a text file, then find it in the terminal.  Next step:  writing a PERL script, then (hopefully) running it!<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pursuing summer tutoring, we have embarked upon the PERL programming journey.\u00a0 The tutor continues it:\u00a0 soon, there might be no turning back. In my previous article, I described how you might, in Windows, create a text file, save it, then &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/perl-programming-using-the-terminal-in-linux-or-mac\/\"> <span class=\"screen-reader-text\">Perl programming:  using the terminal in Linux (or Mac?)<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[167,173,172],"class_list":["post-4732","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-getting-started-with-perl","tag-perl-programming","tag-terminal-on-linux"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/4732","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=4732"}],"version-history":[{"count":33,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/4732\/revisions"}],"predecessor-version":[{"id":4765,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/4732\/revisions\/4765"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=4732"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=4732"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=4732"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}