<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->

<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<!-- 4. Activate & Run Importer. -->
<!-- 5. Upload this file using the form provided on that page. -->
<!-- 6. You will first be asked to map the authors in this export file to users -->
<!--    on the site. For each author, you may choose to map to an -->
<!--    existing user on the site or to create a new user. -->
<!-- 7. WordPress will then import each of the posts, pages, comments, categories, etc. -->
<!--    contained in this file into your site. -->

	<!-- generator="WordPress/6.8.1" created="2025-06-10 14:28" -->
<rss version="2.0"
	xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:wp="http://wordpress.org/export/1.2/"
>

<channel>
	<title>Productivity in Common Operating Systems</title>
	<link>https://pressbooks.library.torontomu.ca/opsyshiraki</link>
	<description>Open Textbook</description>
	<pubDate>Tue, 10 Jun 2025 14:28:07 +0000</pubDate>
	<language>en-US</language>
	<wp:wxr_version>1.2</wp:wxr_version>
	<wp:base_site_url>https://pressbooks.library.torontomu.ca/</wp:base_site_url>
	<wp:base_blog_url>https://pressbooks.library.torontomu.ca/opsyshiraki</wp:base_blog_url>

		<wp:author><wp:author_id>2</wp:author_id><wp:author_login><![CDATA[swilson]]></wp:author_login><wp:author_email><![CDATA[swilson@torontomu.ca]]></wp:author_email><wp:author_display_name><![CDATA[Sally Wilson]]></wp:author_display_name><wp:author_first_name><![CDATA[Sally]]></wp:author_first_name><wp:author_last_name><![CDATA[Wilson]]></wp:author_last_name></wp:author>
	<wp:author><wp:author_id>1</wp:author_id><wp:author_login><![CDATA[patrick.fung]]></wp:author_login><wp:author_email><![CDATA[patrick.fung@torontomu.ca]]></wp:author_email><wp:author_display_name><![CDATA[patrick.fung]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>
	<wp:author><wp:author_id>335</wp:author_id><wp:author_login><![CDATA[lhiraki]]></wp:author_login><wp:author_email><![CDATA[lhiraki@ryerson.ca]]></wp:author_email><wp:author_display_name><![CDATA[lhiraki]]></wp:author_display_name><wp:author_first_name><![CDATA[]]></wp:author_first_name><wp:author_last_name><![CDATA[]]></wp:author_last_name></wp:author>

		<wp:category>
		<wp:term_id>1</wp:term_id>
		<wp:category_nicename><![CDATA[uncategorized]]></wp:category_nicename>
		<wp:category_parent><![CDATA[]]></wp:category_parent>
		<wp:cat_name><![CDATA[Uncategorized]]></wp:cat_name>
	</wp:category>
				<wp:term>
		<wp:term_id>24</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[about-the-author]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[About the Author]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>25</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[about-the-publisher]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[About the Publisher]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>3</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[abstracts]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Abstract]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>4</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[acknowledgements]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Acknowledgements]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>26</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[acknowledgements]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Acknowledgements]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>27</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[afterword]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Afterword]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>59</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[all-rights-reserved]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[All Rights Reserved]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>28</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[appendix]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Appendix]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>29</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[authors-note]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Author's Note]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>30</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[back-of-book-ad]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Back of Book Ad]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>5</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[before-title]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Before Title Page]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>31</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[bibliography]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Bibliography]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>32</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[biographical-note]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Biographical Note]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>53</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY (Attribution)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>56</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by-nc]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY-NC (Attribution NonCommercial)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>58</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by-nc-nd]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY-NC-ND (Attribution NonCommercial NoDerivatives)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>57</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by-nc-sa]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY-NC-SA (Attribution NonCommercial ShareAlike)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>55</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by-nd]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY-ND (Attribution NoDerivatives)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>54</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-by-sa]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC BY-SA (Attribution ShareAlike)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>52</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[cc-zero]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[CC0 (Creative Commons Zero)]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>6</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[chronology-timeline]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Chronology, Timeline]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>33</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[colophon]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Colophon]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>34</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[conclusion]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Conclusion]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>2</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[contributors]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Contributors]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>35</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[credits]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Credits]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>7</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[dedication]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Dedication]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>36</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[dedication]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Dedication]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>8</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[disclaimer]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Disclaimer]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>9</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[epigraph]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Epigraph]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>37</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[epilogue]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Epilogue]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>10</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[foreword]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Foreword]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>11</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[genealogy-family-tree]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Genealogy, Family Tree]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>38</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[glossary]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Glossary]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>12</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[image-credits]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Image credits]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>39</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[index]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Index]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>13</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[introduction]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Introduction]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>61</wp:term_id>
		<wp:term_taxonomy><![CDATA[contributor]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[lhiraki]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Lester Hiraki]]></wp:term_name>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_first_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Lester]]></wp:meta_value>
		</wp:termmeta>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_last_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Hiraki]]></wp:meta_value>
		</wp:termmeta>
	</wp:term>
		<wp:term>
		<wp:term_id>63</wp:term_id>
		<wp:term_taxonomy><![CDATA[contributor]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[lhiraki-2]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[lhiraki]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>14</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[list-of-abbreviations]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[List of Abbreviations]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>15</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[list-of-characters]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[List of Characters]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>16</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[list-of-illustrations]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[List of Illustrations]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>17</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[list-of-tables]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[List of Tables]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>40</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[miscellaneous]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Miscellaneous]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>50</wp:term_id>
		<wp:term_taxonomy><![CDATA[glossary-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[miscellaneous]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Miscellaneous]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>18</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[miscellaneous]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Miscellaneous]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>62</wp:term_id>
		<wp:term_taxonomy><![CDATA[contributor]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[nkuruppu]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Nipuni Kuruppu]]></wp:term_name>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_first_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Nipuni]]></wp:meta_value>
		</wp:termmeta>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_last_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Kuruppu]]></wp:meta_value>
		</wp:termmeta>
	</wp:term>
		<wp:term>
		<wp:term_id>41</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[notes]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Notes]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>49</wp:term_id>
		<wp:term_taxonomy><![CDATA[chapter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[numberless]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Numberless]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>42</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[other-books]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Other Books by Author]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>19</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[other-books]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Other Books by Author]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>43</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[permissions]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Permissions]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>20</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[preface]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Preface]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>21</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[prologue]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Prologue]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>51</wp:term_id>
		<wp:term_taxonomy><![CDATA[license]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[public-domain]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Public Domain]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>44</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[reading-group-guide]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Reading Group Guide]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>22</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[recommended-citation]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Recommended citation]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>45</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[resources]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Resources]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>60</wp:term_id>
		<wp:term_taxonomy><![CDATA[contributor]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[swilson]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Sally Wilson]]></wp:term_name>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_first_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Sally]]></wp:meta_value>
		</wp:termmeta>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_last_name]]></wp:meta_key>
			<wp:meta_value><![CDATA[Wilson]]></wp:meta_value>
		</wp:termmeta>
		<wp:termmeta>
			<wp:meta_key><![CDATA[contributor_picture]]></wp:meta_key>
			<wp:meta_value><![CDATA[https://pressbooks.library.ryerson.ca/wp-content/uploads/sites/330/2018/04/profile.jpg]]></wp:meta_value>
		</wp:termmeta>
	</wp:term>
		<wp:term>
		<wp:term_id>46</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[sources]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Sources]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>48</wp:term_id>
		<wp:term_taxonomy><![CDATA[chapter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[standard]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Standard]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>47</wp:term_id>
		<wp:term_taxonomy><![CDATA[back-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[suggested-reading]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Suggested Reading]]></wp:term_name>
	</wp:term>
		<wp:term>
		<wp:term_id>23</wp:term_id>
		<wp:term_taxonomy><![CDATA[front-matter-type]]></wp:term_taxonomy>
		<wp:term_slug><![CDATA[title-page]]></wp:term_slug>
		<wp:term_parent><![CDATA[]]></wp:term_parent>
		<wp:term_name><![CDATA[Title Page]]></wp:term_name>
	</wp:term>
		
	<generator>https://wordpress.org/?v=6.8.1</generator>

		<item>
		<title><![CDATA[profile]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/profile/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/wp-content/uploads/sites/330/2018/04/profile.jpg</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>17</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[profile]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2018/04/profile.jpg]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2018/04/profile.jpg]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:400;s:6:"height";i:400;s:4:"file";s:19:"2018/04/profile.jpg";s:5:"sizes";a:5:{s:6:"medium";a:4:{s:4:"file";s:19:"profile-300x300.jpg";s:5:"width";i:300;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";}s:9:"thumbnail";a:4:{s:4:"file";s:19:"profile-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";}s:14:"pb_cover_small";a:4:{s:4:"file";s:17:"profile-65x65.jpg";s:5:"width";i:65;s:6:"height";i:65;s:9:"mime-type";s:10:"image/jpeg";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:19:"profile-225x225.jpg";s:5:"width";i:225;s:6:"height";i:225;s:9:"mime-type";s:10:"image/jpeg";}s:14:"pb_cover_large";a:4:{s:4:"file";s:19:"profile-350x350.jpg";s:5:"width";i:350;s:6:"height";i:350;s:9:"mime-type";s:10:"image/jpeg";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[hierarchical_file_sys (1)]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/hierarchicalfilesystem/hierarchical_file_sys-1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/hierarchical_file_sys-1.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>24</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[hierarchical_file_sys-1]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>25</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/hierarchical_file_sys-1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/hierarchical_file_sys-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:663;s:6:"height";i:465;s:4:"file";s:35:"2022/03/hierarchical_file_sys-1.png";s:5:"sizes";a:5:{s:6:"medium";a:4:{s:4:"file";s:35:"hierarchical_file_sys-1-300x210.png";s:5:"width";i:300;s:6:"height";i:210;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:35:"hierarchical_file_sys-1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:33:"hierarchical_file_sys-1-65x46.png";s:5:"width";i:65;s:6:"height";i:46;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:35:"hierarchical_file_sys-1-225x158.png";s:5:"width";i:225;s:6:"height";i:158;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:35:"hierarchical_file_sys-1-350x245.png";s:5:"width";i:350;s:6:"height";i:245;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_image_alt]]></wp:meta_key>
		<wp:meta_value><![CDATA[]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[The Hierarchical File System]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/hierarchicalfilesystem/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/hierarchicalfilesystem/</guid>
		<description></description>
		<content:encoded><![CDATA[<h2 id="h.7k54okhymdw0" class="c12 c29"><span class="c9">Pre-amble</span></h2>
<p class="c18"><span class="c1">Unix is primarily a command line oriented operating system.  Most commands are an action which is performed on an object, typically a file or directory.  In order to be productive in a Unix environment, one must be intimately familiar with the concept of the hierarchical file system.  Mastering this concept is fundamental to successful work in a Unix environment and is the key takeaway of this section.</span></p>

<h1 id="h.c9tx9mli4ian" class="c29"><span class="c15">Hierarchical File System</span></h1>
<p class="c2"><span class="c1">The Unix file system is that of an inverted tree.  Imagine a tree with leaves and branches but turned upside down with the root or main trunk at the top.  The main trunk branches off to smaller branches and eventually leaves.  By analogy, the root directory typically contains several directories (folders) which in turn contain other directories (subdirectories) and/or files.  Just as a tree branch can have smaller branches or leaves, a leaf cannot have other branches or leaves.  Similarly, the difference between a directory and a file is that a directory can contain other directories or files, but a file cannot contain other directories or files -- a file is a terminal node.</span></p>
<p class="c2"><span class="c1">The figure below shows the typical layout of a Unix file system.  While systems vary greatly in size, most will have at least these directories.  The convention in this diagram uses an ellipse to depict a directory and a rectangle to depict a file.</span></p>


[caption id="attachment_24" align="alignnone" width="537"]<img src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/hierarchical_file_sys-1-300x210.png" alt=" Ellipse containing / at top, 4 ellipses connected with lines beneath top ellipse containing words etc, bin, dev, users. Rectangles beneath ellipses represent files." width="537" height="376" class="wp-image-24" title="Hierarchical File - Title" /> Typical hierarchical file structure of a Unix system[/caption]

&nbsp;
<p class="c2"><span class="c1">Explanation of common subdirectories:</span></p>

<table class="grid" style="border-collapse: collapse;width: 100%" border="0">
<thead>
<tr>
<th style="width: 22.3701%" scope="col">
<h3>Directory</h3>
</th>
<th style="width: 77.6299%" scope="col">
<h3>Remarks</h3>
</th>
</tr>
</thead>
<tbody>
<tr>
<th style="width: 22.3701%" scope="row">etc</th>
<td style="width: 77.6299%">contains operation and administrative files</td>
</tr>
<tr>
<th style="width: 22.3701%" scope="row">bin</th>
<td style="width: 77.6299%">contains executable commands</td>
</tr>
<tr>
<th style="width: 22.3701%" scope="row">dev</th>
<td style="width: 77.6299%"><span class="c1">contains the devices connected to the system (printers, terminals, etc...); these devices still appear as files</span></td>
</tr>
<tr>
<th style="width: 22.3701%" scope="row">users*</th>
<td style="width: 77.6299%">contains user files and directories. *The directory name is not standard and varies between systems.  Other common variations are things like "home".  Some larger systems will even have more than one top-level user directories such as "faculty", "staff", "classof31", etc.</td>
</tr>
</tbody>
</table>
<h2 id="h.1w47277fkjat" class="c29"><span class="c9">How to Specify a File or Directory in Unix</span></h2>
<p class="c2 no-indent"><span class="c1">As most Unix commands act on files or directories, it is </span>necessary to be able to specify such an entity.</p>
There are two methods to specify a file or directory, absolute and relative:
<h3 class="c2 c12" id="h.wlex4i7yj2gn"><span class="c11">Absolute</span></h3>
<p class="c2"><span class="c1">To specify a file or directory using the absolute method, start with the root directory (/) and write each directory that is encountered on the path to the directory or file being specified.  Separate each directory with a "/" forward slash character.</span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Examples</p>

</header>
<div class="textbox__content">Specify the etc directory in the above system.</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5">/etc</span></pre>
<div class="textbox__content">Specify the file named passwd in the above system.</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5">/etc/passwd</span></pre>
<div class="textbox__content">Specify the file named ls in the above system.</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5">/bin/ls</span></pre>
<div class="textbox__content">Specify the file named mydata in the above system.</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5">/users/raj/work/mydata</span></pre>
<pre class="textbox__content indent" style="padding-left: 40px"></pre>
</div>
&nbsp;
<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaways</p>

</header>
<div class="textbox__content">The absolute specification <span class="c17">always </span><span class="c1">starts with a "/" (forward slash).</span></div>
</div>
&nbsp;
<h3 class="c2 c12" id="h.ckuga4i1jzvp"><span class="c11">Relative</span></h3>
<p class="c2"><span class="c1">When working on Unix, the user will always "be'' at some logical position within the hierarchy.  This position is termed the "current working directory" or simply the "current directory". The specification of a relative path is relative to this current directory position.  Note that it is possible to change one's current directory while working; this will be discussed in a later chapter.</span></p>
<p class="c2"><span class="c1">To specify a file or directory using the relative method, start with the current directory and write each directory that is encountered on the path to the directory or file being specified.  Separate each directory with a "/" forward slash character.</span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Examples</p>

</header>
<div class="textbox__content">
<div class="textbox__content">
<p class="c2"><span class="c1">Specify the file mydata with </span><span class="c1">current directory: /users/raj/</span></p>

</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5"><span class="c5 c3">work/mydata
</span></span></pre>
<div class="textbox__content">
<p class="c2"><span class="c1">Specify the file mydata with </span><span class="c1">current directory: /users/raj/work/</span></p>

</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5"><span class="c5 c3">mydata</span></span></pre>
<div class="textbox__content">
<p class="c2"><span class="c1">Specify the file report with </span><span class="c1">current directory: /users/raj/work</span></p>

</div>
<pre class="textbox__content indent" style="padding-left: 40px"><span class="c3 c5"><span class="c5 c3">../report</span></span></pre>
<p class="textbox__content indent no-indent"><span class="c3 c5"><span class="c5 c3"> <span class="c1">As the file <strong>report</strong> is not contained in the current directory, it is necessary to go up one level first (to raj) to be able to reach the file <strong>report</strong>.  Here the double dots mean "parent directory" or one level up.</span></span></span></p>

</div>
</div>
&nbsp;
<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaways</p>

</header>
<div class="textbox__content">The relative specification <span class="c17">never </span><span class="c1">starts with a "/" (forward slash).</span></div>
</div>
<p class="c2 c16"><span class="c1"> </span></p>
<p class="c2"><span class="c1">When should one use absolute vs. relative specifications?  In many cases both are acceptable.  One may notice that a relative specification usually requires less typing.  Who likes more typing? An absolute path is preferred when the user or programmer values portability allowing the specification to be used from any position on the system by any user.</span></p>

<h3 class="c2 c12" id="h.trgvb3y0wgo"><span class="c11">Points to Consider</span></h3>
<ul class="c19 lst-kix_558yn0im65zn-0 start">
 	<li class="c2 c22 c20 li-bullet-0"><span class="c1">Names for files and directories are case-sensitive.  Thus report, Report, and REPORT are all distinct.</span></li>
 	<li class="c2 c22 c20 li-bullet-0"><span class="c1">Names may include any letters, digits, and some special characters (period, comma, underscore, etc.) but not /, &lt;, &gt;, &amp;, :, |. </span></li>
 	<li class="c2 c22 c20 li-bullet-0"><span class="c1">Names may be up to 255 characters in length.</span></li>
 	<li class="c2 c22 c20 li-bullet-0"><span class="c1">There is no requirement for file extensions (few characters after a period).  All of the following are valid names:</span></li>
</ul>
<ul>
 	<li style="list-style-type: none">
<ul class="c19 lst-kix_558yn0im65zn-1 start">
 	<li class="c2 c21 li-bullet-0">
<pre><span class="c1">report</span></pre>
</li>
 	<li class="c2 c21 li-bullet-0">
<pre><span class="c1">letter_to_bob.text</span></pre>
</li>
 	<li class="c2 c21 li-bullet-0">
<pre><span class="c1">forecast.July,Version1</span></pre>
</li>
 	<li class="c2 c21 li-bullet-0">
<pre><span class="c1">notes.doc</span></pre>
</li>
</ul>
</li>
</ul>
<ul class="c19 lst-kix_558yn0im65zn-0">
 	<li class="c2 c22 c20 li-bullet-0"><span class="c1">Names must be unique within a directory (no duplicates allowed).  This is automatically enforced by the operating system.  In the raj directory, it would not be possible to create another file or directory called work.  Consider the analogy of human families:  Two siblings would not share the same name, but a cousin, uncle, or grandparent could share the same name without conflict.</span></li>
</ul>
<span>[h5p id="1"]</span>
<h2 id="h.lropx7ndtkj" class="c12 c39"><span class="c9">Home Directory</span></h2>
<p class="c2"><span class="c1">The home directory is a private area for the user files and directories. Each user will have a directory name matching the login name assigned by the system administrator. </span></p>
<p class="c2"><span class="c1">While it is correct and possible to specify a home directory using the absolute and relative methods aforementioned, there exists an abbreviation consisting of a ~ (tilde) followed by the user’s login name.  Advantage: This avoids having to know the name of the user file area which is non-standard:  some installations call it users, others call it home, still others have their own conventions.  </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Examples</p>

</header>
<div class="textbox__content">
<p class="c2">Eg. Raj's home directory would be</p>

<pre class="c2" style="padding-left: 40px"><span class="c5 c3">~raj</span></pre>
<p class="c2">Eg. A file in his directory would be</p>

<pre class="c2" style="padding-left: 40px"><span class="c5 c3">~raj/report</span></pre>
</div>
</div>
&nbsp;

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>25</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-04-27 14:02:58]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-04-27 18:02:58]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[hierarchicalfilesystem]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Common Unix Commands]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/common-unix-commands/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/common-unix-commands/</guid>
		<description></description>
		<content:encoded><![CDATA[<p class="c2"><span class="c1">While there are hundreds of Unix commands, fortunately it is not necessary to know all of them.  In fact, one can achieve a significant level of productivity knowing just a couple of dozen.  Here are some of the most common and useful commands.</span></p>
<p class="c2"><span class="c1">All commands are case sensitive.</span></p>

<div class="textbox shaded">
<h3 id="h.gr7e4fwomdd4">Spaces are a BIG DEAL in Unix</h3>
<p class="c2"><span class="c1">When issuing commands, in order for Unix to tell when a command finishes and when parameters and file names start and end, every item (or token) on a command line must be separated by whitespace (one or more space characters).  One of the most common causes of frustration is failure to put whitepace between items on the command line, or putting whitespace where it should not be.</span></p>
<p class="c2"><span class="c1">Just as in English, there is a big difference in meaning between "no table" and "notable", so is the case in Unix.</span></p>
<p class="c2"><span class="c1">Right: </span></p>

<pre class="c2" style="padding-left: 40px;"><span class="c1">ls /etc</span></pre>
<p class="c2"><span class="c1">Wrong: </span></p>

<pre class="c2" style="padding-left: 40px;"><span class="c1">ls/etc</span></pre>
</div>
&nbsp;

Unix commands are a single word requesting an action.  Sometimes the action is standalone, but most actions are applied to some object like a file or directory.  At the point in the command where it expects the name of a file, say, this is where you specify the file in the form of an absolute or relative reference as described in the previous chapter.
<table class="grid" style="border-collapse: collapse; width: 87.5444%;" border="0">
<thead>
<tr>
<th style="width: 15.7161%;" scope="col">
<h3>Command</h3>
</th>
<th style="width: 24.588%;" scope="col">
<h3>What does it do?</h3>
</th>
<th style="width: 47.2413%;" scope="col">
<h3>Example usage</h3>
</th>
</tr>
</thead>
<thead>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>ls</pre>
</th>
<td style="width: 24.588%;">list directory contents</td>
<td style="width: 47.2413%;">List files (and directories) in my current directory
<pre style="padding-left: 40px;">ls</pre>
List files in top level etc directory
<pre style="padding-left: 40px;">ls /etc</pre>
List all files beginning with g in the current directory. (The * is a wildcard.)
<pre style="padding-left: 40px;">ls g*</pre>
List and give details about files in the current directory
<pre style="padding-left: 40px;">ls -l</pre>
List all files including hidden files (those having a name beginning with a period character) in the current directory
<pre style="padding-left: 40px;">ls -a</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>cat</pre>
</th>
<td style="width: 24.588%;">concatenate files and print on the standard output</td>
<td style="width: 47.2413%;">show contents of file report (in current directory)
<pre style="padding-left: 40px;">cat report</pre>
show contents of files chapter1 and chapter2
<pre style="padding-left: 40px;">cat chapter1 chapter2</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>head</pre>
</th>
<td style="width: 24.588%;">output the first part of files</td>
<td style="width: 47.2413%;">show the first few lines of file longfile
<pre style="padding-left: 40px;">head longfile</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>tail</pre>
</th>
<td style="width: 24.588%;">output the last part of files</td>
<td style="width: 47.2413%;">show the last few lines of file logfile
<pre style="padding-left: 40px;">tail logfile</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>cp</pre>
</th>
<td style="width: 24.588%;">copy files and directories</td>
<td style="width: 47.2413%;">copy file report to report_v2 in the work directory
<pre style="padding-left: 40px;">cp report work/report_v2</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>mv</pre>
</th>
<td style="width: 24.588%;">move (rename) files</td>
<td style="width: 47.2413%;">rename file report to presentation
<pre style="padding-left: 40px;">mv report presentation</pre>
move file mydata to yourdata one level up
<pre style="padding-left: 40px;">mv mydata ../yourdata</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>rm</pre>
</th>
<td style="width: 24.588%;">remove files (permanent)</td>
<td style="width: 47.2413%;">delete file report in current directory
<pre style="padding-left: 40px;">rm report</pre>
Caution:  There is no recycling bin in Unix.  You should consider all deletions as permanent.  Exercise care when using wildcards (e.g. *).</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>cd</pre>
</th>
<td style="width: 24.588%;">change the working directory</td>
<td style="width: 47.2413%;">change directory to work directory (one level down)
<pre style="padding-left: 40px;">cd work</pre>
change directory to /bin directory
<pre style="padding-left: 40px;">cd /bin</pre>
change directory to parent (one level up)
<pre style="padding-left: 40px;">cd ..</pre>
change directory to home directory of user ahmed
<pre style="padding-left: 40px;">cd ~ahmed</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>pwd</pre>
</th>
<td style="width: 24.588%;">print name of current/working directory</td>
<td style="width: 47.2413%;">Are you lost?
<pre style="padding-left: 40px;">pwd</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>mkdir</pre>
</th>
<td style="width: 24.588%;">make directories</td>
<td style="width: 47.2413%;">create new directory called unix_exercises in the current directory
<pre style="padding-left: 40px;">mkdir unix_exercises</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>rmdir</pre>
</th>
<td style="width: 24.588%;">remove empty directories</td>
<td style="width: 47.2413%;">remove (permanently delete) the directory unix_exercises from current directory
<pre style="padding-left: 40px;">rmdir unix_exercises</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>who</pre>
</th>
<td style="width: 24.588%;">show who is logged on</td>
<td style="width: 47.2413%;">display who else is logged in right now
<pre style="padding-left: 40px;">who</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>whoami</pre>
</th>
<td style="width: 24.588%;">print effective userid</td>
<td style="width: 47.2413%;">display one's one userid (short login name)
<pre style="padding-left: 40px;">whoami</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>date</pre>
</th>
<td style="width: 24.588%;">print the system date and time</td>
<td style="width: 47.2413%;">
<pre style="padding-left: 40px;">date</pre>
</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>man</pre>
</th>
<td style="width: 24.588%;">an interface to the on-line reference manuals</td>
<td style="width: 47.2413%;">display the manual entry for the ls command
<pre style="padding-left: 40px;">man ls</pre>
Not sure of what command to look for?  Try a keyword search.  Display all commands pertaining to "directory"
<pre style="padding-left: 40px;">man -k directory</pre>
&nbsp;</td>
</tr>
</thead>
</table>
&nbsp;

&nbsp;
<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaways</p>

</header>
<div class="textbox__content">
<ul>
 	<li>Spaces are a BIG DEAL in Unix:  They are needed between commands, parameters, and filenames.</li>
 	<li>All commands are case-sensitive (usually all lowercase)</li>
</ul>
</div>
</div>
<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">More Key Takeaways</p>

</header>
<div class="textbox__content">
<ul>
 	<li>Command options (e.g. -l, or -d, etc.) are specific to the command.  For example, while both the ls and and cp command both have a "-l" option, the option means different things in each command.  Command options are <strong>not</strong> mix and match.</li>
 	<li>Command options may be listed separately or combined.  The following are equivalent:
<ul>
 	<li>
<pre>ls -ld</pre>
</li>
 	<li>
<pre>ls -l -d</pre>
</li>
</ul>
</li>
</ul>
&nbsp;

</div>
</div>
<h2>More Unix Commands</h2>
<div class="textbox shaded">All the commands below require some sort of input, typically a file, but the commands do <strong>not</strong> modify the input file.  The outputs will contain portions of the input files, but the input files are never changed.</div>
&nbsp;
<table class="grid" style="border-collapse: collapse; width: 100%;" border="0">
<thead>
<tr>
<th style="width: 15.7161%;" scope="col">
<h3>Command</h3>
</th>
<th style="width: 24.588%;" scope="col">
<h3>What does it do?</h3>
</th>
<th style="width: 59.6958%;" scope="col">
<h3>Example usage</h3>
</th>
</tr>
</thead>
<tbody>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>cut</pre>
</th>
<td style="width: 24.588%;">Print selected parts of lines from each FILE to standard output.</td>
<td style="width: 59.6958%;">display columns 1-10 and 20-23 of myfile
<pre style="padding-left: 40px;">cut -c1-10,20-23 myfile</pre>
display the 3rd and 5th fields of the /etc/passwd file
<pre style="padding-left: 40px;">cut -f3,5 -d: /etc/passwd</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>paste</pre>
</th>
<td style="width: 24.588%;">merge lines of files

If cat joins vertically, think of paste as a horizontal version of cat.</td>
<td style="width: 59.6958%;">display file1, file2, and file3 side-by-side
<pre style="padding-left: 40px;">paste file1 file2 file3</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>wc</pre>
</th>
<td style="width: 24.588%;">print newline, word, and byte counts for each file</td>
<td style="width: 59.6958%;">display the number of lines, words, and characters for the file chapter3
<pre style="padding-left: 40px;">wc chapter3</pre>
display only the number of lines
<pre style="padding-left: 40px;">wc -l chapter3</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>grep</pre>
</th>
<td style="width: 24.588%;">print lines matching a pattern</td>
<td style="width: 59.6958%;">display lines matching the string Total in the file sales
<pre style="padding-left: 40px;">grep Total sales</pre>
&nbsp;</td>
</tr>
<tr>
<th style="width: 15.7161%;" scope="row">
<pre>sort</pre>
</th>
<td style="width: 24.588%;">sort lines of text files</td>
<td style="width: 59.6958%;">display a sorted version of the file namelist
<pre style="padding-left: 40px;">sort namelist</pre>
&nbsp;</td>
</tr>
</tbody>
</table>
&nbsp;

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>26</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-06-10 10:26:14]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-06-10 14:26:14]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[common-unix-commands]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>2</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[4]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image4]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image4/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image4.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>27</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image4]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image4.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image4.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:902;s:6:"height";i:237;s:4:"file";s:18:"2022/03/image4.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:17:"image4-300x79.png";s:5:"width";i:300;s:6:"height";i:79;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image4-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image4-768x202.png";s:5:"width";i:768;s:6:"height";i:202;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image4-65x17.png";s:5:"width";i:65;s:6:"height";i:17;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:17:"image4-225x59.png";s:5:"width";i:225;s:6:"height";i:59;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:17:"image4-350x92.png";s:5:"width";i:350;s:6:"height";i:92;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image6]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image6/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:14 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image6.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>28</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:14]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:14]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image6]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image6.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image6.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:939;s:6:"height";i:447;s:4:"file";s:18:"2022/03/image6.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:18:"image6-300x143.png";s:5:"width";i:300;s:6:"height";i:143;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image6-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image6-768x366.png";s:5:"width";i:768;s:6:"height";i:366;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image6-65x31.png";s:5:"width";i:65;s:6:"height";i:31;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:18:"image6-225x107.png";s:5:"width";i:225;s:6:"height";i:107;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:18:"image6-350x167.png";s:5:"width";i:350;s:6:"height";i:167;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image7]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image7/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:14 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image7.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>29</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:14]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:14]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image7]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image7.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image7.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:939;s:6:"height";i:447;s:4:"file";s:18:"2022/03/image7.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:18:"image7-300x143.png";s:5:"width";i:300;s:6:"height";i:143;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image7-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image7-768x366.png";s:5:"width";i:768;s:6:"height";i:366;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image7-65x31.png";s:5:"width";i:65;s:6:"height";i:31;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:18:"image7-225x107.png";s:5:"width";i:225;s:6:"height";i:107;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:18:"image7-350x167.png";s:5:"width";i:350;s:6:"height";i:167;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image3]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image3/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:14 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>30</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:14]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:14]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image3]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image3.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:939;s:6:"height";i:447;s:4:"file";s:18:"2022/03/image3.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:18:"image3-300x143.png";s:5:"width";i:300;s:6:"height";i:143;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image3-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image3-768x366.png";s:5:"width";i:768;s:6:"height";i:366;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image3-65x31.png";s:5:"width";i:65;s:6:"height";i:31;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:18:"image3-225x107.png";s:5:"width";i:225;s:6:"height";i:107;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:18:"image3-350x167.png";s:5:"width";i:350;s:6:"height";i:167;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image5]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image5/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:15 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image5.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>31</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:15]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:15]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image5]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image5.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image5.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:939;s:6:"height";i:447;s:4:"file";s:18:"2022/03/image5.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:18:"image5-300x143.png";s:5:"width";i:300;s:6:"height";i:143;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image5-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image5-768x366.png";s:5:"width";i:768;s:6:"height";i:366;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image5-65x31.png";s:5:"width";i:65;s:6:"height";i:31;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:18:"image5-225x107.png";s:5:"width";i:225;s:6:"height";i:107;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:18:"image5-350x167.png";s:5:"width";i:350;s:6:"height";i:167;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image1]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:15 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>32</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:15]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:15]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image1]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:939;s:6:"height";i:447;s:4:"file";s:18:"2022/03/image1.png";s:5:"sizes";a:6:{s:6:"medium";a:4:{s:4:"file";s:18:"image1-300x143.png";s:5:"width";i:300;s:6:"height";i:143;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:18:"image1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:12:"medium_large";a:4:{s:4:"file";s:18:"image1-768x366.png";s:5:"width";i:768;s:6:"height";i:366;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:16:"image1-65x31.png";s:5:"width";i:65;s:6:"height";i:31;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:18:"image1-225x107.png";s:5:"width";i:225;s:6:"height";i:107;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:18:"image1-350x167.png";s:5:"width";i:350;s:6:"height";i:167;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image2]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/image2/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>33</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image2]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>34</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image2.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:47;s:6:"height";i:20;s:4:"file";s:18:"2022/03/image2.png";s:5:"sizes";a:0:{}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Input and Output: Redirection and Pipes]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/inputoutput/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/lecture-2-part-2-2/</guid>
		<description></description>
		<content:encoded><![CDATA[<p class="c15"><span class="c7">By design most Unix commands are small and simple in their functionality.  To solve beyond the trivial requires the use of several steps or commands.  How to sequence and combine commands in Unix requires an understanding of how input and output is managed.  The next sections will introduce these concepts and show how more complex problems may be solved.</span></p>

<h1 id="h.wt6mdxt54xsg" class="c4"><span class="c26">Filters</span></h1>
<p class="c15">One may think of a filter as a black box with an input and an output. Most Unix commands can be thought of as a filter.  The inputs and outputs have been given formal names. The input is named <span class="c37">standard input </span>(STDIN); the output is named <span class="c37">standard output </span>(STDOUT); and there is a secondary output named <span class="c37">standard error </span><span class="c7"> (STDERR) which will be discussed in more detail later.  These inputs and outputs are associated with file descriptors or stream numbers 0, 1, and 2 respectively.</span></p>
<p class="c2">By default, Unix commands read from standard input and print to standard output.   Any error messages are sent to standard error.
<span style="overflow: hidden; margin: 0.00px 0.00px; border: 0.00px solid #000000; width: 624.00px; height: 164.00px;">
<img alt=" arrow on left points from standard input to box containing word &quot;filter&quot;; two arrows project from right of box 1. standard output 2. standard error" src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image4.png" style="width: 624.00px; height: 164.00px; margin-left: 0.00px; margin-top: 0.00px;" width="902" height="237" class="alignnone" />
</span></p>

<h2 id="h.bvaaykkz6xnq" class="c0"><span class="c5">Examples of Unix commands as filters</span></h2>
<table class="grid" style="height: 178px;">
<tbody>
<tr>
<th style="width: 71.0026px;"><span class="c7">Command</span></th>
<th style="width: 612.852px;">
<p class="c10"><span class="c7">Description</span></p>
</th>
</tr>
<tr class="c9" style="height: 30px;">
<th class="c32" style="height: 30px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">cut</span></pre>
</th>
<th class="c13" style="height: 30px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">reads from standard input and passes selected portions (columns, fields) to standard output</span></p>
</th>
</tr>
<tr class="c9" style="height: 30px;">
<th class="c32" style="height: 30px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">grep</span></pre>
</th>
<th class="c13" style="height: 30px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">reads from standard input and prints matching lines to standard output</span></p>
</th>
</tr>
<tr class="c9" style="height: 28px;">
<th class="c32" style="height: 28px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">head &amp; tail</span></pre>
</th>
<th class="c13" style="height: 28px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">reads from standard input and prints the first (last) few lines to standard output</span></p>
</th>
</tr>
<tr class="c9" style="height: 30px;">
<th class="c32" style="height: 30px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">cat </span></pre>
</th>
<th class="c13" style="height: 30px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">a transparent filter: reads from standard input and prints the same to standard output</span></p>
</th>
</tr>
<tr class="c9" style="height: 30px;">
<th class="c32" style="height: 30px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">wc</span></pre>
</th>
<th class="c13" style="height: 30px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">reads from standard input and prints summary information to standard output</span></p>
</th>
</tr>
<tr class="c9" style="height: 30px;">
<th class="c32" style="height: 30px; width: 71.0026px;" scope="row">
<pre class="c10"><span class="c7">...</span></pre>
</th>
<th class="c13" style="height: 30px; width: 612.852px;" scope="row">
<p class="c10"><span class="c7">not an exhaustive list</span></p>
</th>
</tr>
</tbody>
</table>
<h1 id="h.6mekb4q7u4cf" class="c0"><span class="c26">Redirection</span></h1>
<p class="c15"><span class="c7">When working interactively in a Unix session, the default setup is to have standard input draw from the keyboard, and standard output (as well as standard error) directed at the screen.  In other words, a command reading from standard input will wait for keystrokes. A command printing to standard output will have its output appear on the terminal screen.</span></p>


[caption id="" align="alignnone" width="939"]<img alt="arrow points from keyboard to filter box; two arrows emanate from filter both directed at screen" src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image6.png" style="width: 624.00px; height: 297.33px; margin-left: 0.00px; margin-top: 0.00px;" width="939" height="447" /> Default association of keyboard and screen to filter.[/caption]
<p class="c15"><span class="c7">While this arrangement works well, there will come situations where the user will want to save the output of a command to a file, or substitute a file for keyboard input.  This is accomplished through the concept of redirection where one of the inputs or outputs is associated with a file.</span></p>

<h2 id="h.gss9xc26v69s" class="c41 c11"><span class="c5">Redirection of standard output ( &gt; operator)</span></h2>
<p class="c2"><span class="c7"> </span><span class="c7">The user can save the standard output of any Unix command by redirecting standard output to a file using the &gt; operator.  Graphically, the concept is illustrated as follows.</span></p>


[caption id="" align="alignnone" width="939"]<img alt="arrow points from keyboard to filter box; standard output arrow aims at file; standard error arrow aims at screen." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image7.png" style="width: 624.00px; height: 297.33px; margin-left: 0.00px; margin-top: 0.00px;" width="939" height="447" /> Redirection of Standard Output[/caption]
<table class="grid">
<tbody>
<tr>
<th><span class="c14 c12">Operator syntax</span></th>
<td>
<p class="c8">Examples and explanation</p>
</td>
</tr>
<tr class="c28">
<th class="c31" scope="row">
<pre class="c8"><span class="c14 c12">cmd &gt; some_file</span></pre>
</th>
<td class="c29">
<p class="c8">e.g.</p>

<pre class="c8"><span class="c14 c12">cat chapter1 &gt; book</span></pre>
<ul class="c3 lst-kix_eni0n9t8gcec-0 start">
 	<li class="c16 c21 li-bullet-0"><span class="c19"> </span><span class="c7">if the file already exists it will overwrite it</span></li>
</ul>
</td>
</tr>
<tr class="c39">
<th class="c31" scope="row">
<pre class="c8"><span class="c14 c12">cmd &gt;&gt; some_file</span></pre>
</th>
<td class="c29">
<p class="c8">e.g.</p>

<pre class="c8"><span class="c12 c14">cat chapter3 &gt;&gt; book</span></pre>
<ul class="c3 lst-kix_5ixwda23g4fh-0 start">
 	<li class="c21 c16 li-bullet-0"><span class="c7">the &gt;&gt; operator appends an existing file</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<h2 id="h.sb2v99olmxe6" class="c0"><span class="c5">Redirecting standard error ( 2&gt; operator)</span></h2>
<p class="c15"><span class="c7">The user can save the standard error of any Unix command by redirecting standard error to a file using the 2&gt; operator. Graphically, the concept is illustrated as follows.</span></p>


[caption id="" align="alignnone" width="939"]<img alt="arrow points from keyboard to filter box; standard output arrow aims at screen; standard error arrow aims at file." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3.png" style="width: 624.00px; height: 297.33px; margin-left: 0.00px; margin-top: 0.00px;" width="939" height="447" /> Redirection of Standard Error[/caption]
<table class="grid" style="width: 486px;">
<tbody>
<tr>
<th style="width: 208.6px;"><span class="c14 c12">Operator syntax</span></th>
<td style="width: 249.167px;">
<p class="c8">Examples and explanation</p>
</td>
</tr>
<tr class="c46">
<th class="c31" style="width: 208.6px;" scope="row">
<pre class="c8"><span class="c14 c12">cmd 2&gt; some_file</span></pre>
</th>
<td class="c29" style="width: 249.167px;">
<pre class="c8">e.g.
<span class="c12">cat chapter1 </span><span class="c12">chapter4 </span><span class="c14 c12">2&gt; errors</span></pre>
<p class="c6"><span class="c14 c12"> </span></p>

<ul class="c3 lst-kix_45riwvqygofu-0 start">
 	<li class="c10 c16 c48 li-bullet-0">saves error messages in file errors but standard output is displayed on the screen</li>
</ul>
</td>
</tr>
<tr class="c34">
<th class="c31" style="width: 208.6px;" scope="row">
<pre class="c8"><span class="c14 c12">cmd &gt; some_file 2&gt; another_file</span></pre>
</th>
<td class="c29" style="width: 249.167px;">
<pre class="c8">e.g.
<span class="c14 c12">cat chapter1 &gt; book 2&gt; errors</span></pre>
<p class="c6"><span class="c14 c12"> </span></p>

<ul class="c3 lst-kix_87jixnldtqct-0 start">
 	<li class="c10 c48 c16 li-bullet-0"><span class="c7">saves standard output to file book, and saves standard error messages in file errors</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<h2 id="h.shd9x97a7p7v" class="c0"><span class="c5">Merging two streams ( &gt;&amp; operator)</span></h2>
<p class="c2"><span class="c7"> </span><span class="c7">The user can save both standard output and standard error of any Unix command.  This is accomplished by first redirecting standard error to a file, and then merging standard error with standard output.  The syntax of the merge operator is m&gt;&amp;n where stream m is merged with wherever stream n is already going.   Graphically, the concept is illustrated as follows.  Here stream 2 (standard error) is merged with stream 1 (standard output).</span></p>
<p class="c2"><span class="c7"> </span><img alt="arrow points from keyboard to filter box; two arrows emanate from filter both directed to a plus symbol showing a merge; one arrow goes from plus symbol to file." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image5.png" width="939" height="447" style="width: 624.00px; height: 297.33px; margin-left: 0.00px; margin-top: 0.00px;" /></p>
<p class="c2">Standard Output and Standard Error are merged (combined) and re-directed to a file</p>

<table class="grid" style="width: 336px; height: 196px;">
<tbody>
<tr style="height: 38px;">
<th style="width: 164.797px; height: 38px;"><span class="c14 c12">Operator syntax</span></th>
<td style="width: 459.828px; height: 38px;">
<p class="c8">Examples and explanation</p>
</td>
</tr>
<tr class="c45" style="height: 258px;">
<td class="c40" style="width: 164.797px; height: 258px;">
<pre class="c8"><span class="c14 c12">cmd &gt; out_file 2&gt;&amp;1</span></pre>
</td>
<td class="c47" style="width: 459.828px; height: 258px;">
<pre class="c8">e.g.
<span class="c14 c12">cat text1 junk text3 &gt; both 2&gt;&amp;1</span></pre>
<ul class="c3 lst-kix_6iqymci964mf-0 start">
 	<li class="c21 c16 li-bullet-0"><span class="c7">saves standard output and standard error to file both</span></li>
 	<li class="c21 c16 li-bullet-0"><span class="c7">Explanation: Unix parses left to right.  First standard output is redirected to file "both".  Then the merge operator (&gt;&amp;) merges (blends) standard error (stream 2) with where standard output (stream 1) is already going (to file "both").</span></li>
 	<li class="c21 c16 li-bullet-0">Caution: How about
<pre><span class="c14 c12">cat text1 junk text3 &gt; both 2&gt; both</span></pre>
</li>
</ul>
<ul class="c3 lst-kix_6iqymci964mf-1 start">
 	<li class="c21 c52 li-bullet-0"><span class="c7">This is an incorrect method of trying to merge two streams.  This causes a race condition (two streams competing for the same file) and correct results are not guaranteed.</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<h2 id="h.9i31k9ol401" class="c0"><span class="c5">Redirecting standard input ( &lt; operator)</span></h2>
<p class="c15"><span class="c7">The user can redirect standard input from a file instead of the keyboard to any Unix command using the &lt; operator.  Graphically, the concept is illustrated as follows.</span></p>


[caption id="" align="alignnone" width="939"]<img alt="arrow points from file to filter box; two arrows emanate from filter both directed at screen" src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1.png" style="width: 624.00px; height: 297.33px; margin-left: 0.00px; margin-top: 0.00px;" width="939" height="447" /> Redirection of Standard Input from a file[/caption]
<table class="grid" style="width: 615px; height: 314px;">
<tbody>
<tr>
<th style="width: 165.875px;"><span class="c14 c12">Operator syntax</span></th>
<td style="width: 458.75px;">
<p class="c8">Examples and explanation</p>
</td>
</tr>
<tr class="c45">
<td class="c40" style="width: 165.875px;">
<pre class="c8"><span class="c14 c12">cmd &lt; some_file</span></pre>
</td>
<td class="c47" style="width: 458.75px;">
<pre class="c8"><span class="c7">cat &lt; appendix</span></pre>
<p class="c21"><span class="c7">While it may appear that the "&lt;" in the above command does not seem to do anything (works the same without the "&lt;"), the reason is that the cat command is smart and knows to look for input on the command line.  Unless a command is specifically designed to inspect the command line for input arguments, it is necessary to use the "&lt;" for redirection of standard input.  </span></p>
<p class="c21"><span class="c7">Consider a more basic example of a simple script requesting input from the keyboard.  To substitute a file, it would be necessary to issue the following command, where the file "keystrokes" contains what the user would have typed.</span></p>

<pre id="h.p94fyfyj5b4m" class="c21 c11"><span class="c14 c12">myscript &lt; keystrokes</span></pre>
<p class="c21 c22"><span class="c7">Here "myscript" represents a user-written Unix script (program), not a Unix command.</span></p>
</td>
</tr>
</tbody>
</table>
<h1 id="h.1a28qkewep1a" class="c0"><span class="c26">Pipes</span></h1>
<p class="c15"><span class="c7">It is often the case that a problem in Unix is solved with multiple commands.  Typically the output of the first command is saved in a file which is then used as input to a subsequent command.  The use of a pipe is considered a refinement of this approach potentially simplifying the solution.</span></p>

<h2 class="c33"><span class="c7">Problem: To determine the number of entries in a directory</span></h2>
<h3>Method 1</h3>
<table class="grid">
<thead>
<tr class="c9">
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c1"><span class="c7">Graphical view</span></p>
</th>
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c10"><span class="c7">code</span></p>
</th>
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c10"><span class="c7">explanation</span></p>
</th>
</tr>
</thead>
<tbody>
<tr class="c9">
<td class="c18" colspan="1" rowspan="1">
<p class="c1">ls -&gt;
<span class="c50">file_list </span>
<span class="c7">-&gt; wc</span></p>
</td>
<td class="c18" colspan="1" rowspan="1">
<pre id="h.ckhvq4jx782t" class="c1 c11"><span class="c14 c12">ls /etc &gt; file_list</span>
<span class="c14 c12">wc -l file_list</span>
rm file_list</pre>
</td>
<td class="c18" colspan="1" rowspan="1">
<ul class="c3 lst-kix_2j8r3h84ts86-0 start">
 	<li class="c10 c16 li-bullet-0"><span class="c7">save output of ls command in file_list</span></li>
 	<li class="c10 c16 li-bullet-0"><span class="c7">run wc command to count lines</span></li>
 	<li class="c10 c16 li-bullet-0"><span class="c7">delete temporary file file_list</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<h3>Method 2</h3>
<table class="grid">
<thead>
<tr class="c9">
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c1"><span class="c7">Graphical view</span></p>
</th>
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c10"><span class="c7">code</span></p>
</th>
<th class="c18" colspan="1" rowspan="1" scope="col">
<p class="c10"><span class="c7">explanation</span></p>
</th>
</tr>
</thead>
<tbody>
<tr class="c9">
<td class="c18" colspan="1" rowspan="1">
<pre class="c33">ls -&gt;
<span style="overflow: hidden; margin: 0.00px 0.00px; border: 0.00px solid #000000; width: 65.31px; height: 20.00px;">
<img alt="" src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2.png" style="width: 65.31px; height: 20.00px; margin-left: 0.00px; margin-top: 0.00px;" title="" />
</span>
<span class="c7"> -&gt; wc </span>

<span class="c7"> </span></pre>
</td>
<td class="c18" colspan="1" rowspan="1">
<pre class="c17 c36"><span class="c12">ls /etc | wc -l</span></pre>
</td>
<td class="c18" colspan="1" rowspan="1">
<ul class="c3 lst-kix_2j8r3h84ts86-0">
 	<li class="c10 c16 li-bullet-0"><span class="c7">save output of ls command is sent directly to input of wc command</span></li>
 	<li class="c10 c16 li-bullet-0"><span class="c7">no temporary file needed</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="c20"><span class="c7"> </span></p>

<div class="textbox">
<h2 class="c33"><span class="c37">Definition:</span></h2>
<p class="c33"><span class="c7">A pipe connects STDOUT of previous command to STDIN of next command</span></p>

</div>
<p class="c33"><span class="c7">You can use a pipe multiple times creating a pipeline.</span></p>

<pre class="c30">e.g.
<span class="c14 c12">cmd1 | cmd2 | cmd3 | cmd4</span></pre>
<p class="c33"><span class="c7">Building a pipeline should be an iterative process. Condense stepwise as you know the solutions work, otherwise there might be errors that might be difficult to detect from a single pipeline</span></p>
<p class="c33"><span class="c7">Start out like this:</span></p>

<pre id="h.69mc4iy1lwkm" class="c0"><span class="c14 c12">
cmd1 &gt; out1</span>
cmd2 &lt; out1 &gt; out2
cmd3 &lt; out2</pre>
...
<p class="c20"><span class="c7"> </span></p>

<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaways</p>

</header>
<div class="textbox__content">
<ol>
 	<li class="c17 c36"><span class="c19"> </span><span class="c37">Redirection</span><span class="c7">: Use between a command and a file</span></li>
 	<li class="c17 c36"> Pipe<span class="c7" style="text-align: initial; font-size: 1em;">: Use between commands</span></li>
</ol>
</div>
</div>

<hr />

<h1 class="c2"><span class="c7"> </span><span class="c5">Making your script executable</span></h1>
<ol class="c3 lst-kix_w9cpc76ivqci-0 start" start="1">
 	<li class="c15 c16 li-bullet-0"><span class="c7">create file containing unix commands</span></li>
 	<li class="c15 c16 li-bullet-0"><span class="c7">Once per file, type either:</span>
<ul class="c3 lst-kix_w9cpc76ivqci-0 start">
 	<li><span class="c7">chmod u+x myscript</span></li>
 	<li><span class="c7">chmod 700 myscript</span></li>
</ul>
</li>
 	<li class="c15 c16 li-bullet-0"><span class="c7">To run, type ./myscript</span></li>
</ol>
<p class="c2"><span class="c7"> </span></p>
&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>34</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-04-29 14:16:22]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-04-29 18:16:22]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[inputoutput]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>3</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[4]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_old_slug]]></wp:meta_key>
		<wp:meta_value><![CDATA[lecture-2-part-2-2]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image1-1]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct1/image1-1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-1.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>36</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:16]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image1-1]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>37</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image1-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:519;s:6:"height";i:170;s:4:"file";s:20:"2022/03/image1-1.png";s:5:"sizes";a:5:{s:6:"medium";a:4:{s:4:"file";s:19:"image1-1-300x98.png";s:5:"width";i:300;s:6:"height";i:98;s:9:"mime-type";s:9:"image/png";}s:9:"thumbnail";a:4:{s:4:"file";s:20:"image1-1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:18:"image1-1-65x21.png";s:5:"width";i:65;s:6:"height";i:21;s:9:"mime-type";s:9:"image/png";}s:15:"pb_cover_medium";a:4:{s:4:"file";s:19:"image1-1-225x74.png";s:5:"width";i:225;s:6:"height";i:74;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_large";a:4:{s:4:"file";s:20:"image1-1-350x115.png";s:5:"width";i:350;s:6:"height";i:115;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image3-1]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct2/image3-1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3-1.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>38</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:17]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image3-1]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>41</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3-1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image3-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:178;s:6:"height";i:257;s:4:"file";s:20:"2022/03/image3-1.png";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:20:"image3-1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:18:"image3-1-65x94.png";s:5:"width";i:65;s:6:"height";i:94;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image2-1]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct2/image2-1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:17 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2-1.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>39</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:17]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:17]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image2-1]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>41</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2-1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image2-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:181;s:6:"height";i:262;s:4:"file";s:20:"2022/03/image2-1.png";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:20:"image2-1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:18:"image2-1-65x94.png";s:5:"width";i:65;s:6:"height";i:94;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[image1-2]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct2/image1-2/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:17 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-2.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>40</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:17]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:17]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[image1-2]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>41</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-2.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2022/03/image1-2.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:5:{s:5:"width";i:190;s:6:"height";i:268;s:4:"file";s:20:"2022/03/image1-2.png";s:5:"sizes";a:2:{s:9:"thumbnail";a:4:{s:4:"file";s:20:"image1-2-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";}s:14:"pb_cover_small";a:4:{s:4:"file";s:18:"image1-2-65x92.png";s:5:"width";i:65;s:6:"height";i:92;s:9:"mime-type";s:9:"image/png";}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Acknowledgements]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/back-matter/acknowledgements/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:17 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/back-matter/acknowledgements/</guid>
		<description></description>
		<content:encoded><![CDATA[I would first like to thank my wife, Sylvie, for her holistic support.

There are many people in the Toronto Metropolitan University (formerly Ryerson University) community who supported me academically, technically and editorially.  While it is not possible to mention everyone who influenced the development of this book, I wish to acknowledge the following individuals:

<span style="font-size: 1em">Anne-Marie Brinsmead, </span><span>Maryam Davoudpour, </span>Alex Ferworn, <span>Greg Gay, </span><span>Shannon Koumphol, </span><span>Ann Ludbrook, </span><span style="font-size: 1em">Allen Pader, </span>Mehrdad  Tirandazian, <span>Muhammad Waqas, </span>Sally Wilson, and <span>Leonora Zefi.</span>

Without their support and endorsement, this book would not have been created.

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>44</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:17]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-05-20 10:32:00]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-05-20 14:32:00]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[acknowledgements]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[back-matter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
										<category domain="back-matter-type" nicename="appendix"><![CDATA[Appendix]]></category>
						<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[cover]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/cover-2/</link>
		<pubDate>Sun, 27 Apr 2025 18:20:23 +0000</pubDate>
		<dc:creator><![CDATA[lhiraki]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/04/cover.jpg</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>94</wp:post_id>
		<wp:post_date><![CDATA[2025-04-27 14:20:23]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2025-04-27 18:20:23]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-04-27 14:20:23]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-04-27 18:20:23]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[open]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[cover-2]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/04/cover-scaled.jpg]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2025/04/cover-scaled.jpg]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:7:{s:5:"width";i:1707;s:6:"height";i:2560;s:4:"file";s:24:"2025/04/cover-scaled.jpg";s:8:"filesize";i:205077;s:5:"sizes";a:9:{s:6:"medium";a:5:{s:4:"file";s:17:"cover-200x300.jpg";s:5:"width";i:200;s:6:"height";i:300;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:12823;}s:5:"large";a:5:{s:4:"file";s:18:"cover-683x1024.jpg";s:5:"width";i:683;s:6:"height";i:1024;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:66603;}s:9:"thumbnail";a:5:{s:4:"file";s:17:"cover-150x150.jpg";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:6579;}s:12:"medium_large";a:5:{s:4:"file";s:18:"cover-768x1152.jpg";s:5:"width";i:768;s:6:"height";i:1152;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:77504;}s:9:"1536x1536";a:5:{s:4:"file";s:19:"cover-1024x1536.jpg";s:5:"width";i:1024;s:6:"height";i:1536;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:109622;}s:9:"2048x2048";a:5:{s:4:"file";s:19:"cover-1365x2048.jpg";s:5:"width";i:1365;s:6:"height";i:2048;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:156663;}s:14:"pb_cover_small";a:5:{s:4:"file";s:15:"cover-65x98.jpg";s:5:"width";i:65;s:6:"height";i:98;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:2506;}s:15:"pb_cover_medium";a:5:{s:4:"file";s:17:"cover-225x338.jpg";s:5:"width";i:225;s:6:"height";i:338;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:15108;}s:14:"pb_cover_large";a:5:{s:4:"file";s:17:"cover-350x525.jpg";s:5:"width";i:350;s:6:"height";i:525;s:9:"mime-type";s:10:"image/jpeg";s:8:"filesize";i:27340;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}s:14:"original_image";s:9:"cover.jpg";}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[PiCOS-TMU]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/picos-tmu/</link>
		<pubDate>Sun, 04 May 2025 12:53:27 +0000</pubDate>
		<dc:creator><![CDATA[lhiraki]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/05/PiCOS-TMU.png</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>106</wp:post_id>
		<wp:post_date><![CDATA[2025-05-04 08:53:27]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2025-05-04 12:53:27]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-05-04 08:53:27]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-05-04 12:53:27]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[picos-tmu]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/05/PiCOS-TMU.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2025/05/PiCOS-TMU.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:6:{s:5:"width";i:1346;s:6:"height";i:1386;s:4:"file";s:21:"2025/05/PiCOS-TMU.png";s:8:"filesize";i:141769;s:5:"sizes";a:7:{s:6:"medium";a:5:{s:4:"file";s:21:"PiCOS-TMU-291x300.png";s:5:"width";i:291;s:6:"height";i:300;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:8833;}s:5:"large";a:5:{s:4:"file";s:22:"PiCOS-TMU-994x1024.png";s:5:"width";i:994;s:6:"height";i:1024;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:33855;}s:9:"thumbnail";a:5:{s:4:"file";s:21:"PiCOS-TMU-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:4351;}s:12:"medium_large";a:5:{s:4:"file";s:21:"PiCOS-TMU-768x791.png";s:5:"width";i:768;s:6:"height";i:791;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:25470;}s:14:"pb_cover_small";a:5:{s:4:"file";s:19:"PiCOS-TMU-65x67.png";s:5:"width";i:65;s:6:"height";i:67;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:2031;}s:15:"pb_cover_medium";a:5:{s:4:"file";s:21:"PiCOS-TMU-225x232.png";s:5:"width";i:225;s:6:"height";i:232;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:6525;}s:14:"pb_cover_large";a:5:{s:4:"file";s:21:"PiCOS-TMU-350x360.png";s:5:"width";i:350;s:6:"height";i:360;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:10499;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Cover Image]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/?attachment_id=107</link>
		<pubDate>Sun, 04 May 2025 12:54:31 +0000</pubDate>
		<dc:creator><![CDATA[lhiraki]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.torontomu.ca/opsyshiraki/?attachment_id=107</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>107</wp:post_id>
		<wp:post_date><![CDATA[2025-05-04 08:54:31]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2025-05-04 12:54:31]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-05-04 08:54:31]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-05-04 12:54:31]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[pb-cover-image]]></wp:post_name>
		<wp:status><![CDATA[inherit]]></wp:status>
		<wp:post_parent>16</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[attachment]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
						<wp:attachment_url><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/05/PiCOS-TMU-1.png]]></wp:attachment_url>
											<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attached_file]]></wp:meta_key>
		<wp:meta_value><![CDATA[2025/05/PiCOS-TMU-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_wp_attachment_metadata]]></wp:meta_key>
		<wp:meta_value><![CDATA[a:6:{s:5:"width";i:1346;s:6:"height";i:1386;s:4:"file";s:23:"2025/05/PiCOS-TMU-1.png";s:8:"filesize";i:143796;s:5:"sizes";a:7:{s:6:"medium";a:5:{s:4:"file";s:23:"PiCOS-TMU-1-291x300.png";s:5:"width";i:291;s:6:"height";i:300;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:8833;}s:5:"large";a:5:{s:4:"file";s:24:"PiCOS-TMU-1-994x1024.png";s:5:"width";i:994;s:6:"height";i:1024;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:33855;}s:9:"thumbnail";a:5:{s:4:"file";s:23:"PiCOS-TMU-1-150x150.png";s:5:"width";i:150;s:6:"height";i:150;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:4351;}s:12:"medium_large";a:5:{s:4:"file";s:23:"PiCOS-TMU-1-768x791.png";s:5:"width";i:768;s:6:"height";i:791;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:25470;}s:14:"pb_cover_small";a:5:{s:4:"file";s:21:"PiCOS-TMU-1-65x67.png";s:5:"width";i:65;s:6:"height";i:67;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:2031;}s:15:"pb_cover_medium";a:5:{s:4:"file";s:23:"PiCOS-TMU-1-225x232.png";s:5:"width";i:225;s:6:"height";i:232;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:6525;}s:14:"pb_cover_large";a:5:{s:4:"file";s:23:"PiCOS-TMU-1-350x360.png";s:5:"width";i:350;s:6:"height";i:360;s:9:"mime-type";s:9:"image/png";s:8:"filesize";i:10499;}}s:10:"image_meta";a:12:{s:8:"aperture";s:1:"0";s:6:"credit";s:0:"";s:6:"camera";s:0:"";s:7:"caption";s:0:"";s:17:"created_timestamp";s:1:"0";s:9:"copyright";s:0:"";s:12:"focal_length";s:1:"0";s:3:"iso";s:1:"0";s:13:"shutter_speed";s:1:"0";s:5:"title";s:0:"";s:11:"orientation";s:1:"0";s:8:"keywords";a:0:{}}}]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Authors]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/authors/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/authors/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>7</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[authors]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Cover]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/cover/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>8</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[cover]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Table of Contents]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/table-of-contents/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/table-of-contents/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>9</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[table-of-contents]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[About]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/about/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/about/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>10</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[about]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Buy]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/buy/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/buy/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>11</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[buy]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Access Denied]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/access-denied/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/access-denied/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>12</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[access-denied]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>0</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Book Information]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/?metadata=book-information</link>
		<pubDate>Fri, 04 Mar 2022 20:09:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/?p=16</guid>
		<description></description>
		<content:encoded><![CDATA[]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>16</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-05-04 08:54:30]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-05-04 12:54:30]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[book-information]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[metadata]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
										<category domain="license" nicename="cc-by-nc"><![CDATA[CC BY-NC (Attribution NonCommercial)]]></category>
		<category domain="contributor" nicename="lhiraki"><![CDATA[Lester Hiraki]]></category>
						<wp:postmeta>
		<wp:meta_key><![CDATA[pb_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[Productivity in Common Operating Systems]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_language]]></wp:meta_key>
		<wp:meta_value><![CDATA[en-ca]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_cover_image]]></wp:meta_key>
		<wp:meta_value><![CDATA[https://pressbooks.library.torontomu.ca/opsyshiraki/wp-content/uploads/sites/330/2025/05/PiCOS-TMU-1.png]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_primary_subject]]></wp:meta_key>
		<wp:meta_value><![CDATA[UMX]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_book_license]]></wp:meta_key>
		<wp:meta_value><![CDATA[cc-by-nc]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_subtitle]]></wp:meta_key>
		<wp:meta_value><![CDATA[Unix Essentials]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_publisher]]></wp:meta_key>
		<wp:meta_value><![CDATA[Toronto Metropolitan University]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_publisher_city]]></wp:meta_key>
		<wp:meta_value><![CDATA[Toronto]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_publication_date]]></wp:meta_key>
		<wp:meta_value><![CDATA[1653004800]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_copyright_holder]]></wp:meta_key>
		<wp:meta_value><![CDATA[Lester Hiraki]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_additional_subjects]]></wp:meta_key>
		<wp:meta_value><![CDATA[UM]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_authors]]></wp:meta_key>
		<wp:meta_value><![CDATA[lhiraki]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_keywords_tags]]></wp:meta_key>
		<wp:meta_value><![CDATA[]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_bisac_subject]]></wp:meta_key>
		<wp:meta_value><![CDATA[]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[H5P listing]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/h5p-listing/</link>
		<pubDate>Fri, 04 Mar 2022 20:09:18 +0000</pubDate>
		<dc:creator><![CDATA[patrick.fung]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/h5p-listing/</guid>
		<description></description>
		<content:encoded><![CDATA[<!-- Here be dragons. -->]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>21</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:09:18]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:09:18]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:09:18]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:09:18]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[h5p-listing]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[page]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Introduction]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/front-matter/introduction-2/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/front-matter/introduction-2/</guid>
		<description></description>
		<content:encoded><![CDATA[Welcome to Productivity in Common Operating Systems!

The goal of this book is to provide the interested learner with the essentials to work in a Unix environment.

The focus is on the user's perspective to enable the user to be productive in a Unix environment.  Topics include understanding and navigating the file system, using common commands, and automating tasks.  Emphasizing the user's perspective, the scope of this book does not include topics such as system administration, installation, or networking.

To gain the most out of this book, it is recommended that the learner have access to a Unix or Unix-like system, specifically with command line access, so as to be able to practice commands and programming.

This book is intended for adoption in the freshman or sophomore year of a technical program (e.g. computer science, engineering, STEM, etc.).  No prior knowledge or experience with Unix is expected; however, familiarity with computer programming (coding and debugging) is strongly recommended.

UNIX is a registered trademark of The Open Group.  The Open Group is not affiliated with this resource.  <span>Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.  </span>In this book, Unix (mixed case) refers to Unix-like operating systems such as Linux as well as UNIX.]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>22</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-05-04 08:44:57]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-05-04 12:44:57]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[introduction-2]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[front-matter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
										<category domain="front-matter-type" nicename="introduction"><![CDATA[Introduction]]></category>
		<category domain="contributor" nicename="lhiraki"><![CDATA[Lester Hiraki]]></category>
						<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[pb_authors]]></wp:meta_key>
		<wp:meta_value><![CDATA[lhiraki]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Main Body]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/part/main-body-2/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:13 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/part/main-body-2/</guid>
		<description></description>
		<content:encoded><![CDATA[

]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>23</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:13]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-03-04 15:11:13]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-03-04 20:11:13]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[main-body-2]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>0</wp:post_parent>
		<wp:menu_order>1</wp:menu_order>
		<wp:post_type><![CDATA[part]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														</item>
					<item>
		<title><![CDATA[Shell Variables, Quotes, Command Substitution]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/shellvariables/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/shellvariables/</guid>
		<description></description>
		<content:encoded><![CDATA[<h1>Shell Variables</h1>
<p class="c4"><span class="c0">Unix is an operating system but also the name given to its scripting (programming) language. In order to be useful, a computer language needs to be able to store data. Unix supports this capability with shell variables. </span></p>
<p class="c4"><span class="c0">There are three kinds of shell variables:</span></p>

<ol class="c2 lst-kix_ckfao24sw02h-0 start" start="1">
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">special</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">environment</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">program</span></li>
</ol>
<h2 id="h.g9x11nt2qx8t" class="c13 c6"><span class="c10">Special variables</span></h2>
<p class="c4"><span class="c0">Special variables are unlike what you may have seen in other programming languages. Rather special variables are created and set by the operating system automatically. Consider the following examples:</span></p>
<p class="c3"><span class="c0"> </span></p>

<h3 class="c5" id="h.3gv6p8mlyjaa"><span class="c8">Positional parameters ($1, $2, …)</span></h3>
<p class="c4"><span class="c0">Recall that the cat program allows the user to specify inputs as command-line arguments:  (In the following examples, the leading dollar sign represents the command prompt; do not type the leading dollar sign.)</span></p>

<pre class="c4"><span class="c0">$ <strong>cat ch1 ch2 ch3</strong></span></pre>
<p class="c4"><span class="c0">Imagine that you would like to write your own script allowing the user to specify inputs as command-line arguments as in. </span></p>
&nbsp;
<pre class="c4"><span class="c0">$ <strong>myscript apple cherry</strong></span></pre>
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example</p>

</header>
<div class="textbox__content">
<pre class="c4"><span class="c1">$ <strong>cat arg_demo</strong></span>
<span class="c1">#!/bin/bash</span>
<span class="c1">echo The 1st argument is $1</span>
<span class="c1">echo The 2nd argument is $2</span>
$
<span class="c1">$ <strong>./arg_demo apple cherry</strong></span>
<span class="c1">The 1st argument is apple</span>
<span class="c1">The 2nd argument is cherry</span>

</pre>
</div>
</div>
<h3 class="c5" id="h.xrhmgnq10kfz"><span class="c8">number of command line arguments ($#)</span></h3>
<p class="c4"><span class="c0">The special variable $# holds the number of command-line arguments specified when your script was run.</span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Examples</p>

</header>
<div class="textbox__content">
<pre>$ <strong>cat numeg</strong>
<span class="c1">#!/bin/bash
</span><span class="c1">echo The number of command line arguments is $#
$
$ <strong>./numeg apple</strong></span><strong><span class="c1"> cherry
</span></strong><span class="c1">The number of command line arguments is 2
</span>$</pre>
</div>
</div>
&nbsp;
<h3 class="c5" id="h.aq4mywhc5f8f"><span class="c8">return code of previous command ($?)</span></h3>
<p class="c4"><span class="c0">Every Unix command generates a return code typically indicating success or failure. The value of this return code is stored in the special variable $?. Thus each time a Unix command is run the $? variable is updated automatically to hold the return code of the most recently executed Unix command.  The use of the return code is important and will become apparent in the chapter on control structures. </span></p>

<h2 class="c13 c6"><span class="c10">Environment </span><span class="c10">variables</span></h2>
<p class="c4"><span class="c0">Environment variables hold information about the users's current settings and configuration. By convention, they are typically all UPPERCASE. To display them, type ‘env’</span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example</p>

</header>
<div class="textbox__content">
<pre class="c3"><span class="c0">lhiraki@metis:~$ <strong>env</strong>
SHELL=/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin:/usr/courses/bin/x86_64
JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
EDITOR=vi
LANGUAGE=en_CA:en
LPDEST=eng206c
lhiraki@metis:~$
</span></pre>
Here is an abridged list of environment variables.  Some of the typical environment variables include SHELL (current shell), PATH (list of directories the operating system will search in order to find a command), EDITOR (preferred editor), LANGUAGE (preferred display language), LPDEST (preferred printer destination).

</div>
</div>
&nbsp;
<h2 class="c5"><span class="c8">Program </span><span class="c10">variables</span></h2>
<p class="c4"><span class="c0">Program variables are the type of variable that typically come to mind when one thinks of variables in a computer programming language. Program variables are variables which you as the programmer create and set. As Unix is a prototyping language, it is common to dispense with many of the formalities required for variable declarations, etc. </span></p>
<p class="c3"><span class="c0"> </span></p>
<p class="c4"><span class="c0">Program variables hold a string, i.e. text, and can be used anywhere text could appear in a program such as a filename, part of the file name, or even a Unix command itself.  A variable can hold only one value at a time. </span></p>
<p class="c3"><span class="c0"> </span></p>
<p class="c4"><span class="c0">The naming convention for program variables is to use lowercase. Specifically uppercase program variable names should be avoided so as to prevent confusion with environment variables and accidentally overwriting an environment variable.</span></p>
<p class="c3"><span class="c0"> </span></p>
<p class="c3"><span class="c0"> </span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Eg. 1  An easy way to create and set a program variable is using an assignment statement.</span></p>

</header>
<div class="textbox__content">
<pre id="h.7cl5azn9o175" class="c4 c6"><span class="c1">temp_name=/usr/temp</span>
<span class="c1">cp myfile $temp_name</span></pre>
</div>
</div>
<p class="c3"><span class="c0"> </span></p>
<p class="c4"><span class="c0">Assignment statements copy the value to the right of the equal sign to the variable on the left.  Important:  Assignment statements must not contain spaces, especially around the equal sign.</span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Eg. 2</p>

</header>
<div class="textbox__content">
<pre id="h.swweyesv5zvn" class="c4 c6"><span class="c1">month=september </span>
<span class="c1">echo the current month is $month</span></pre>
</div>
</div>
<h3 class="c5" id="h.hzz5ibquuoql"><span class="c8">When to use $ with variables</span></h3>
<p class="c4"><span class="c0">When writing to a variable, i.e. setting or changing its contents, do not use the dollar sign. When reading a variable, i.e. accessing its contents, you must use the dollar sign.</span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaway - <span class="c0">When to use $ with variables:</span></p>

</header>
<div class="textbox__content">
<p class="c4"><span class="c0"><strong>Writing</strong> to a variable: <strong>no</strong> dollar sign</span></p>
<p class="c4"><span class="c0"><strong>Reading</strong> from a variable: <strong>use</strong> dollar sign</span></p>

</div>
</div>
<div class="textbox shaded">
<p class="c3">Editorial Remark:</p>
One of the key factors affected software maintenance costs is code readability.  Most of the time (cost) of maintaining software is spent in having designers read and understand existing code.  One way to control and reduce costs (business competitiveness) is to ease readability.  By choosing variables which reflect their contents, it makes it easier to understand the code.
<p class="c4"><strong><span class="c0">Choose self-describing variable names:</span></strong></p>

<table class="grid" style="border-collapse: collapse;width: 100%;height: 30px" border="0">
<thead>
<tr style="height: 15px">
<th style="width: 50%;height: 15px" scope="col"><span style="font-size: 16px">Good variable names:</span></th>
<th style="width: 50%;height: 15px" scope="col"><span class="c0">Bad variable names:</span></th>
</tr>
</thead>
<tbody>
<tr style="height: 15px">
<td style="width: 50%;height: 15px">
<ul class="c2 lst-kix_furawtezqk8i-0 start">
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">sum </span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">total</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">x_value</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">length </span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">count</span></li>
</ul>
</td>
<td style="width: 50%;height: 15px">
<ul class="c2 lst-kix_14tmntyk4v1-0 start">
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">a,b,c….</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">var1, var2, var3….</span></li>
</ul>
</td>
</tr>
</tbody>
</table>
<span style="text-align: initial;font-size: 1em"> </span>

</div>
<h1 id="h.1bkln71pd17i" class="c13 c6"><span class="c10">read</span></h1>
<p class="c4"><span class="c0">The read command collects characters from standard input (STDIN) and stores them in a variable.  The read command is typically used in an interactive script to collect user input after an appropriate prompt message.  As the read command draws from standard input, and standard input can be redirected from a file, it is possible to prepare inputs (answers) in a file and run the script in a non-interactive fashion.</span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example using read command</p>

</header>
<div class="textbox__content">
<pre id="h.3pe0qxhk8bnw" class="c4 c6"><span class="c1">$ <strong>cat readeg</strong></span>
<span class="c1">echo -n 'What is your name? '</span>
<span class="c1">read name</span>
<span class="c1">echo Hello $name, pleased to meet you!</span>
<span class="c1">$</span>
<span class="c1">$ <strong>./readeg</strong></span>
<span class="c1">What is your name? <strong>Mohammed</strong></span>
<span class="c1">Hello Mohammed, pleased to meet you!</span>
<span class="c1">$</span></pre>
</div>
</div>
<div class="textbox shaded">

What does the option "-n" do in the echo command above?

Hint: type "man echo".  To exit the manual, press "q".

</div>
<div></div>
<div class="textbox textbox--key-takeaways"><header class="textbox__header">
<p class="textbox__title">Key Takeaways</p>

</header>
<div class="textbox__content">
<p class="c4"><span class="c0">read vs. command line arguments</span></p>

<ul>
 	<li class="c4"><span class="c0">Both are ways the user can supply input to a program.  Command line arguments are placed on the command line before pressing &lt;ENTER&gt; to run the program.  The values are accessed within one's program using $1, $2, etc.</span></li>
 	<li class="c4"><span class="c0">The "read" command causes the program to wait for keyboard input (if STDIN has not been redirected from a file).  The input is stored in and later accessed from a program variable.</span></li>
</ul>
<p class="c4"><span class="c0">Which method should you use?  Refer first to any program requirements. (Does it say, "Prompt the user to enter ..." or "specify as a command line argument"?)</span></p>

</div>
</div>
&nbsp;
<h1 id="h.ra7wxgnr4ue" class="c13 c6"><span class="c10">Quotes</span></h1>
<h2 class="c4"><span class="c0">Single quotes:</span></h2>
<p class="c4"><span class="c0">Problem:</span></p>

<pre id="h.a8w4057r77np" class="c4 c6"><span class="c1">$ <strong>grep Al Shaji employee_list</strong></span>
<span class="c1">grep: can’t open Shaji</span></pre>
<p class="c4"><span class="c0">Solution: </span></p>

<pre id="h.c7plh3ux8g64" class="c4 c6"><span class="c1">$ <strong>grep 'Al Shaji' employee_list

</strong></span></pre>
Single quotes causes Unix to take everything within the single quotes literally.  This is how you would prevent interpretation of characters which would normally have special meaning, for example the space character separating command line arguments.
<h2 class="c4"><span class="c0">Double quotes</span></h2>
<ul class="c2 lst-kix_m7najpr6q9vi-0 start">
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">Recognize $, \, ` (backtick or backquote) </span></li>
</ul>
&nbsp;
<div class="textbox textbox--exercises"><header class="textbox__header">
<p class="textbox__title">Exercise 1:  Try this out and see the difference double quotes makes</p>

</header>
<div class="textbox__content">
<pre><span class="c1">heading='    Name     Addr     Phone'</span>
<span class="c1">echo $heading</span>
<span class="c1">echo "$heading"</span></pre>
</div>
</div>
&nbsp;
<div class="textbox textbox--exercises"><header class="textbox__header">
<p class="textbox__title">Exercise 2: <span class="c0">Try this out and see the difference double quotes makes</span></p>

</header>
<div class="textbox__content">
<pre id="h.epuxcm5w1ak8" class="c4 c6 c9"><span class="c1">read operator # enter asterisk *</span>
<span class="c1">echo $operator</span>
<span class="c1">echo "$operator"</span></pre>
</div>
</div>
<p class="c3"><span class="c0">The double quotes are similar to single quotes in that Unix takes what is within the quotes literally.  However, double quotes are "smarter" in that variables and selected meta-characters are interpreted and expanded in spite of the usual literal nature of quotes.  </span></p>
&nbsp;
<h3 class="c4"><span class="c0">Home directory potential tricky issue (tilde is protected i.e. not expanded within quotes).</span></h3>
<p class="c4"><span class="c0">Instead of:</span></p>

<pre id="h.ebrtbg7k6if6" class="c4 c6 c9"><span class="c1">datafile="~jasmin/rawdata"</span>
<span class="c1">cat $datafile  # produces "No such file or directory" error</span></pre>
<p class="c4"><span class="c0">Say (solution 1):</span></p>

<pre id="h.qgl0jf6uwsn3" class="c4 c6 c9"><span class="c1">datafile=~jasmin/rawdata</span>
<span class="c1">cat $datafile</span></pre>
<p class="c4"><span class="c0">Say (solution 2):</span></p>

<pre id="h.t4xu25vepjoa" class="c4 c6 c9"><span class="c1">datafile="~jasmin/rawdata"</span>
<span class="c1">eval cat $datafile</span></pre>
<p class="c3"><span class="c0"> </span></p>

<h1 id="h.tf9sr7lgo2h5" class="c6 c13"><span class="c10">Command substitution</span></h1>
<p class="c4">Sometimes a programmer wishes to run a command and use its output at some point within a program.  While it is possible to redirect output to a temporary file, load the contents of the file, and then promptly delete it, for small tasks, it is more convenient and efficient to use the technique of <em><span class="c7">command substitution </span></em><span class="c0"> and avoid extra disc access. </span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Eg. 1  Newbie's first guess</span></p>

</header>
<div class="textbox__content">
<pre id="h.b9wo8jyt1h4m" class="c4 c6"><span class="c1">today=date</span>
<span class="c1">echo $today</span></pre>
</div>
</div>
&nbsp;
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Eg. 2 This is the way to do it.</span></p>

</header>
<div class="textbox__content">
<pre id="h.eiw5c4qk0n86" class="c4 c6"><span class="c1">today=$(date)  (old version today=`date`)</span>
<span class="c1">echo $today</span></pre>
</div>
</div>
&nbsp;
<p class="c3"><span class="c0"> </span></p>

<div class="textbox">
<p class="c4"><span class="c0">Syntax:</span></p>

<pre id="h.sgrl57ij0835" class="c4 c6 indent"><span class="c1">$(unix_command)</span></pre>
</div>
<p class="c4"><span class="c0">The mechanics of command substitution works as follows:</span></p>

<ol class="c2 lst-kix_uh0507rs9t7n-0 start" start="1">
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">Unix will run the command within the parentheses as if it were typed at the keyboard.  The command may include options, command line arguments, or even be a script.</span></li>
 	<li class="c4 c12 c9 li-bullet-0"><span class="c0">Instead of being displayed on the screen, the standard output (STDOUT) of the command is substituted at the exact position of the call ($(unix_command)).  </span></li>
</ol>
<p class="c3"><span class="c0"> </span></p>
<p class="c4"><span class="c0">The command substitution may be made anywhere in a program; however, it is often used on the right-hand side of an assignment statement (to save the output in a variable), or within an echo statement.</span></p>
&nbsp;

<span>[h5p id="10"]</span>

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>35</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2023-09-01 13:25:15]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2023-09-01 17:25:15]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[shellvariables]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>4</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Control Structures - Part 1 - branching]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct1/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:16 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/controlstruct1/</guid>
		<description></description>
		<content:encoded><![CDATA[<p class="c15"><span class="c0">In order to support control structures (branching, looping, etc.), all computer languages need some method of evaluating a condition.  In Unix, the command to evaluate a condition is the test command.  The test command is often at the heart of most control structures in Unix.</span></p>
&nbsp;
<h1 class="c15"><span class="c0">test</span></h1>
<p class="c15"><span class="c0">What does the test command do?  It evaluates a condition and sets the special shell variable $?, the return code.  Much to the confusion of new users, the test command is silent in that it does not print anything to standard output.  Thus when running the test command, it appears as if to do nothing.  To check the return code, one may simply print its value with an echo statement.</span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Example 1:  Check if a file is readable.</span></p>

</header>
<div class="textbox__content">
<pre id="h.st1gw9c00v55" class="c1 c11"><span class="c2">$ <strong>test -r myfile</strong></span>
<span class="c2">$ <strong>echo $?</strong></span>
<span class="c2">0</span></pre>
</div>
</div>
<p class="c3"><span class="c0"> </span></p>
<p class="c15"><span class="c0">How does one interpret the return code?   </span></p>
<p class="c15"><span class="c0">Unix convention:</span></p>

<table class="grid" style="height: 58px">
<tbody>
<tr class="c25" style="height: 29px">
<th class="c27" style="height: 29px;width: 126.146px" colspan="1" rowspan="1" scope="row">
<p class="c1"><span class="c0">0 (zero)</span></p>
</th>
<td class="c39" style="height: 29px;width: 109.271px" colspan="1" rowspan="1">
<p class="c1"><span class="c0">means TRUE</span></p>
</td>
</tr>
<tr class="c25" style="height: 29px">
<th class="c27" style="height: 29px;width: 126.146px" colspan="1" rowspan="1" scope="row">
<p class="c1"><span class="c0">not 0 (not zero)</span></p>
</th>
<td class="c39" style="height: 29px;width: 109.271px" colspan="1" rowspan="1">
<p class="c1"><span class="c0">means FALSE</span></p>
</td>
</tr>
</tbody>
</table>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Example 2:  Compare if two strings are equal.</span></p>

</header>
<div class="textbox__content">
<pre id="h.g5mey17jgskn" class="c1 c11 "><span class="c2">$ <strong>test "this" = "that"</strong></span>
<span class="c2">$ <strong>echo $?</strong></span>
<span class="c2">1</span></pre>
</div>
</div>
<p class="c3"><span class="c0"> </span></p>

<h2 class="c15"><span class="c0">Synonym to the test command:  [</span></h2>
<p class="c15"><span class="c0">For reasons of readability, many programmers with use the synonym or abbreviation for the test command which is the left square bracket: [ .  In all examples above, replace the word test with the left square bracket.  Note that a matching right square bracket needs to be added for syntactic reasons.  As with all Unix commands, spaces are a big deal and a space is required after the left square bracket and before the right square bracket.</span></p>
<p class="c3"><span class="c0"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Example 3: Synonym to the test command [</span></p>

</header>
<div class="textbox__content">
<pre id="h.3arageq61qd" class="c1 c11">$ <strong>[ -r myfile ]</strong> # <span class="c19 c23">note the space after the left bracket</span>
$ <strong><span class="c2">echo $?</span>
</strong><span class="c2">0</span><span class="c0"> </span></pre>
</div>
</div>
&nbsp;
<h1 id="h.qrw2dg5f4ok8" class="c33 c11"><span class="c30 c26">Control Structures</span></h1>
<h2 id="h.cmha19g1ccek" class="c28 c11"><span class="c29 c26">if</span></h2>
<p class="c15"><span class="c0">The if statement in Unix is the basic two-way branch.</span></p>
&nbsp;
<div class="textbox">
<p class="c15"><span class="c0">Syntax</span></p>

<pre id="h.w0txwnysszi9" class="c1 c11"><span class="c2">if unix_statements</span>
<span class="c2">then</span>
<span class="c2">   actions_true</span>
<span class="c2">else  # optional</span>
<span class="c2">   actions_false</span>
<span class="c2">fi</span></pre>
</div>
<p class="c15"><span class="c0">How does the if statement work?  Here is the sequence of operations.  The if statement will:</span></p>

<ol class="c35 lst-kix_7gl0q3kbqu7q-0 start" start="1">
 	<li class="c15 c37 li-bullet-0"><span class="c0">Run all the unix_statements.   </span></li>
 	<li class="c15 c37 li-bullet-0"><span class="c0">Check the return code ($?) of the last statement in the list (just prior to the keyword "then". </span></li>
 	<li class="c15 c37 li-bullet-0">If the return code is true. the "then" clause is executed (
<span class="c4">actions_true)</span>.  If the return code is false, the "else" clause is executed (<span class="c4">actions_false)</span><span class="c0">.  The else clause is optional (can be left out if not needed).</span></li>
</ol>
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Example of if</span></p>

</header>
<div class="textbox__content">
<pre id="h.kzwhp4rz3e59" class="c1 c11"><span class="c2">#!/bin/bash</span>
<span class="c2">comfort=20</span>
<span class="c2">temperature=18</span>
<span class="c2">if echo The current temperature is $temperature</span>
<span class="c2">   echo Temperature for comparison is $comfort</span>
<span class="c2">   [ $temperature -lt $comfort ]</span>
<span class="c2">then</span>
<span class="c2">  echo It is cold.</span>
<span class="c2">else</span>
<span class="c2">  echo It is warm.</span>
<span class="c2">fi</span><span class="c0"> </span></pre>
</div>
</div>
[h5p id="5"]
<p class="c15"><span class="c0">Nested conditions are supported in Unix.  Any statement in the "then" or "else" clause can itself be another if statement.</span></p>

<h3>elif</h3>
<p class="c15"><span class="c0">Although the if statement is primarily a two-way branch (e.g. true or false), a multi-way branch (e.g. red, yellow, green) can be coded using a set of nested if statements.  Some computer languages support an "else-if"-type clause; Unix is one of them.</span></p>
<p class="c15"><span class="c0">There is an "else-if" clause called "elif" which requires a statement just like the if clause. </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example: elif</p>

</header>
<div class="textbox__content">
<pre id="h.kzwhp4rz3e59-15" class="c1 c11"><span class="c2">if [ $temperature -lt $comfort ]</span>
<span class="c2">then</span>
<span class="c2">  echo It is cold.</span>
<span class="c2">elif [ $temperature -eq $comfort ]</span>
<span class="c2">then</span>
<span class="c2">  echo It is perfect.</span>
<span class="c2">else</span>
<span class="c2">  echo It is warm.</span>
<span class="c2">fi</span>
<span class="c0"> </span></pre>
<p class="c15">Note that the "elif" clause is actually a clause of the main "if" and <span class="c43">not </span><span class="c0">a nested if statement.  Thus, there is only one "fi" (end if) required for each opening "if" regardless of how many "elif" clauses there are.</span></p>

</div>
</div>
<span>[h5p id="6"]</span>

<span>[h5p id="7"]</span>
<h2 id="h.6bd3ulkf9b8a" class="c28 c11">case</h2>
<p class="c15">Many computer languages support a multi-way branch. Unix is included as one of them.</p>

<div class="textbox">
<p class="c15"><span class="c26">Simplified syntax:</span></p>
<p class="c40 c14"><span class="c19 c18"> </span></p>

<pre id="h.r7oy87p532rc" class="c5 c1"><span class="c2">case $variable </span>
<span class="c2">in</span>
<span class="c2">  val1) action1;;</span>
<span class="c2">  val2) action2;;</span>
<span class="c2">  *) default action;;</span>
<span class="c2">esac</span><span class="c19 c18"> </span></pre>
<p class="c15"><span class="c0">The keywords are case, in, and esac.  The double semi-colon is a syntactic requirement to separate the inner clauses of the case statement.</span></p>

</div>
&nbsp;

&nbsp;

&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example:  F<span class="c26">lexible command line processing. </span></p>

</header>
<div class="textbox__content">
<p class="c15"><span class="c26">Allow your user to </span><span class="c0">run your script in various ways.  Accommodate all of the following invocations.</span></p>

<pre class="c3"><span class="c2">$ ./<strong>mysc</strong></span><span class="c2"><strong>ript</strong> </span><span class="c19 c18"># user omits filename; give second chance</span>
$ ./<strong><span class="c2">myscript chapter3</span></strong><span class="c19 c18"> # </span><span class="c18">preferred syntax; just proceed</span>
$ ./<strong><span class="c2">myscript chapter3 chapter5 </span></strong><span class="c19 c18"># multiple arguments not s</span><span class="c18">upported; 
</span><span class="c19 c18">inform user</span>

<span class="c2">Place this code snippet at the beginning of your script like this:</span>
<span class="c2">$ <strong>cat myscript</strong>
case $# in</span>
<span class="c2">  0) echo Enter file name:</span>
<span class="c2">           read arg1;;</span>
<span class="c2">  1) arg1=$1;;</span>
<span class="c2">  *) echo invalid number of arguments</span>
<span class="c2">     echo "Syntax: $0 filename"</span>
<span class="c2">     exit 1;;</span>
<span class="c2">esac</span>
<span class="c2"># rest of program continues after esac
$</span></pre>
</div>
</div>
&nbsp;
<div class="textbox">
<p class="c15"><span style="text-align: initial;font-size: 1em">General syntax:</span><span class="c19 c18"> </span></p>

<pre><span class="c2">case match_string_expr in</span>
<span class="c2">  match_pattern) action1;;</span>
<span class="c2">  match_pattern) action2;;</span>
<span class="c2">  ...</span></pre>
<pre id="h.c44v635lr96i" class="c5 c1">esac</pre>
</div>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title"><span class="c0">Example:  Demonstrate pattern matching use in case statement.  Print a message about the length of the current month.</span></p>

</header>
<div class="textbox__content">
<pre>lhiraki@metis:~/test$ <strong>cat case_month
</strong>case $(date '+%m') in
01|03|05|07|08|10|12)
     echo This is a long month;;
04|06|09|11)
     echo This is a short month;;
02)
     echo This is the shortest month;;
*)
     echo Something wrong with date command;;
esac

# Example run in September

lhiraki@metis:~/test$ <strong>./case_month</strong>
This is a short month
lhiraki@metis:~/test$

</pre>
<p class="c3"><span style="text-align: initial;font-size: 1em">The date command is called with an option to return the numerical value of the month (e.g. Jan=01, Feb=02, etc.).  Depending on the month, a message is printed regarding the length of the month.  Months with the same number of days are grouped together using a pattern with the OR (vertical bar) syntax.</span></p>

</div>
</div>
&nbsp;
<h3 class="c47 c11" id="h.x0r9zvaxt49t"><span class="c48 c26 c43">Defensive programming</span></h3>
<p class="c15"><span class="c0">Well the previous example is rather trivial and the date command has been well tested over the years, it is considered good practice to always have a default clause even if you think you have covered all possible conditions.</span></p>

<h2 class="c15">Summary</h2>
[caption id="" align="alignnone" width="519"]<img alt="Entry arrow points to circle labled case; multiple arrows leave case circle to rectangles each with a separate action; each action has one arrow leaving which are all collected to a common exit." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-1.png" style="width: 519.00px;height: 171.44px;margin-left: 0.00px;margin-top: 0.00px" width="519" height="170" /> Flow of case statement: one entry point, only one action chosen.[/caption]

&nbsp;
<p class="c6"><span class="c19 c23"> </span>The match_string_expr is matched against each match_pattern in the order coded.  At the first match, the corresponding action is taken.  After one action is completed, the case statement terminates and execution continues after the esac (end case).  There is no "fall-through".  The case statement will not execute multiple actions.</p>
<span>[h5p id="8"]</span>
<h2 id="h.df6xnvncbf1j" class="c28 c11">s<span class="c29 c26">hift</span></h2>
<p class="c15"><span class="c0">When processing multiple command-line arguments, it may be necessary to manipulate them to facilitate processing.</span></p>
<p class="c15">The shift command moves all command-line arguments one position to the left.  For example the second command line argument is moved into the first position; the third command line argument is moved into the second position, and so forth.</p>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example of  shift command</p>

</header>
<div class="textbox__content">
<pre id="h.7hj2ijv33hcw" class="c9 c1"><span class="c2">lhiraki@thebe:~/test$ <strong>cat shifter</strong></span>

<span class="c2">#!/bin/bash</span>
<span class="c2">echo The 1st arg is $1</span>
<span class="c2">echo The 2nd arg is $2</span>
<span class="c2">shift</span>
<span class="c2">echo The 2nd arg is $1</span>
<span class="c2">shift</span>
<span class="c2">echo The 3rd arg is $1</span><span class="c19 c18"> </span></pre>
<p class="c32 c36"><span class="c19 c18">Execution results in:</span></p>

<pre id="h.u6zk61ioj0o6" class="c9 c1"><span class="c2">lhiraki@thebe:~/te</span><span class="c2">st$ <strong>./shifter apple pear grape</strong></span>
<span class="c2">The 1st arg is apple</span>
<span class="c2">The 2nd arg is pear</span>
<span class="c2">The 2nd arg is pear</span>
<span class="c2">The 3rd arg is grape</span>
<span class="c2">lhiraki@thebe:~/test$</span></pre>
<p id="h.2myj48q95b02" class="c9 c1 c14"><span class="c2"> </span></p>

</div>
</div>
<h3 class="c11 c47" id="h.n1jlngeudrck">The exit command</h3>
<p class="c15">The exit command <span class="c26">does </span>two<span class="c0"> things:</span></p>

<ol class="c35 lst-kix_lp44ssjvz62w-0 start" start="1">
 	<li class="c15 c37 li-bullet-0">It <span class="c0">terminates the current shell (or script), returning control to the calling shell, if any.</span></li>
 	<li class="c15 c37 li-bullet-0">It <span class="c26">sets the return code ($?) for your script</span>.</li>
</ol>
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example - exit command usage</p>

</header>
<div class="textbox__content">

<span class="c0">The trivial but illustrative script exit_example shows the exit command setting return code for the script to 3 and then terminating the script.  Control returns to the calling program, in this case just back to the operating system prompt.</span>
<pre>$ <strong>cat exit_example</strong>
#!/bin/bash
exit 3
echo This line never executed.

$ <strong>./exit_example</strong>
$ <strong>echo $?</strong>
3
$</pre>
<span class="c0">Note that one must inspect the return code ($?) immediately after running exit_example.  The return code is updated (overwritten) by each Unix command executed. </span>

</div>
</div>
<p class="c15"><span class="c0">The exit command is typically used to terminate a script midway through often due to an errror condition. The other primary use of the exit command is for a sub-script to communicate information back to the calling script.</span></p>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Example - parent/child script relation</p>

</header>
<div class="textbox__content">
<table class="grid" style="width: 284px">
<thead>
<tr class="c25">
<th class="c41" style="width: 199.302px" scope="col">
<p class="c1"><span class="c0">parent</span></p>
</th>
<th class="c12" style="width: 57.8646px" scope="col">
<p class="c1"><span class="c0">child</span></p>
</th>
</tr>
</thead>
<tbody>
<tr class="c25">
<td class="c41" style="width: 199.302px">
<pre class="c1"><span class="c2">./child 
</span><span class="c2">ret_val=$?
</span><span class="c2">case $ret_val</span></pre>
</td>
<td class="c12" style="width: 57.8646px">
<pre id="h.zgjskii3y53y" class="c1 c49"><span class="c2">...</span>
<span class="c2">   exit 2
</span><span class="c2">...
</span><span class="c2">exit 0</span></pre>
</td>
</tr>
</tbody>
</table>
<p class="c40"><span class="c0">Note: parent-child relationship can be used for team project where multiple people can work on the same file at the same time.</span></p>

</div>
</div>
<p class="c3"><span class="c0"> </span></p>

<h2 id="h.9e9qi4h1u243" class="c11 c28"><span class="c26 c29">Shebang line</span></h2>
<p class="c15"><span class="c0">To specify which interpreter Unix should use when executing your script, as the first line of the file place the path to the interpreter after "#!".  While the number sign character (#) normally introduces a comment, when used with the exclamation mark at the beginning of a file, Unix will load the interpreter specified in the path to run the rest of the script file.</span></p>
<p class="c15"><span class="c0">This is especially important to make your script portable in Unix environments.  If you write your script in bash, and you give your script for someone else to use who works in a c-shell or Korn shell environment, your script may not work properly.  To ensure that the script is run under bash, you must specify the shebang line.</span></p>
<p class="c15">Careful:  The shebang line must be the <span class="c43">first line of the file</span><span class="c0">, not just the first line of text, or the first line of code.  A common mistake is to have a blank line as the first line, or some comments above the shebang line.  Unix does not look beyond the first line of the file in order to identify the expected interpreter.</span></p>

<table class="grid">
<thead>
<tr class="c25">
<th class="c22" style="width: 168px" colspan="1" rowspan="1" scope="col">
<p class="c1"><span class="c0">Right</span></p>
</th>
<th class="c22" style="width: 130px" colspan="1" rowspan="1" scope="col">
<p class="c1"><span class="c0">Wrong</span></p>
</th>
<th class="c22" style="width: 117px" colspan="1" rowspan="1" scope="col">
<p class="c1"><span class="c0">Wrong</span></p>
</th>
</tr>
</thead>
<tbody>
<tr class="c25">
<td class="c22" style="width: 168px" colspan="1" rowspan="1">
<pre id="h.k9b970rv56o2" class="c1 c11"><span class="c42">1:#!/bin/bash
</span><span class="c2">2:#comments
</span><span class="c2">3:#comments
</span><span class="c2">4:code begins here        </span></pre>
</td>
<td class="c22" style="width: 130px" colspan="1" rowspan="1">
<pre id="h.gz85vvtz5oro" class="c1 c11"><span class="c2">1:#comments
</span>2:#<span class="c4">comments
</span><span class="c42">3:#!/bin/bash
</span><span class="c2">4:code begins here</span></pre>
</td>
<td class="c22" style="width: 117px" colspan="1" rowspan="1">
<pre id="h.u6ke8weax8l" class="c1 c11 c14"><span class="c42">1:
2:#!/bin/bash
3:
4:</span><span class="c2">code begins here</span></pre>
</td>
</tr>
</tbody>
</table>
<span>[h5p id="9"]</span>

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>37</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:16]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:16]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-05-14 13:27:39]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-05-14 17:27:39]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[controlstruct1]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>5</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
										<category domain="contributor" nicename="lhiraki"><![CDATA[Lester Hiraki]]></category>
						<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Control Structures - Part 2 - Loops]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/controlstruct2/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:17 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/controlstruct2/</guid>
		<description></description>
		<content:encoded><![CDATA[<p class="c13 c21"><span class="c3">Eventually you will need to repeat actions.  A practical way to repeat actions without repeating code is achieved with the construct of a loop. </span></p>

<div class="textbox shaded">
<h1 id="h.32v1nhr0jhri" class="c21 c4"><span class="c25">Computer Science Loop Concepts</span></h1>
<p class="c6"><span class="c3">The construct of a loop allows for the repetition of actions without repeating code.  </span></p>

<h2 class="c5"><span class="c11">General Loop (Concept)</span></h2>
<p class="c6"><span class="c3">The most general flow of control is illustrated in the flowchart below (General).  Observe that there can be a set of actions (Block 1) which is performed regardless on entry into the loop.  Then a conditional check is made to determine continuation of the loop.  If satisfied, further actions within the loop (Block 2) will be performed.  </span></p>
<p class="c5"><span class="c3"> </span></p>
<p class="c6">Not all computer languages support the General loop construct (Unix
<span class="c29">does </span><span class="c3">support a General loop).  If a computer language does not support the General loop construct, it will usually support one or more of the specific cases of the General loop.  For example, C Language supports both a While and a Do-While construct but not the General loop construct.</span></p>

<h2 id="h.s7we9xpua7pz" class="c4 c7"><span class="c11">While Loop (Concept)</span></h2>
<p class="c6"><span class="c3">The While Loop, as a concept, is a special case of a General Loop which has no actions for Block 1.  In this case, the condition is checked as a first action on entry into the loop construct.  See flowchart below (While).</span></p>

<h2 id="h.ds9d1tv3r7e2" class="c7 c4"><span class="c11">Do-While Loop (Concept)</span></h2>
<p class="c6"><span class="c3">The Do-While Loop, as a concept, is a special case of a General Loop which has no actions for Block 2.  In this case, the Block 1 code is executed on entry into the loop construct, and the condition is checked at the end of the loop construct.  See flowchart below (Do-While).</span></p>

<table class="grid">
<thead>
<tr class="c18">
<th class="c8" colspan="1" rowspan="1" scope="col">
<p class="c2"><span class="c3">General</span></p>
</th>
<th class="c8" colspan="1" rowspan="1" scope="col">
<p class="c2"><span class="c3">While</span></p>
</th>
<th class="c8" colspan="1" rowspan="1" scope="col">
<p class="c2"><span class="c3">Do-While</span></p>
</th>
</tr>
</thead>
<tbody>
<tr class="c32">
<td class="c8" colspan="1" rowspan="1">
<p class="c2"><span style="overflow: hidden;margin: 0.00px 0.00px;border: 0.00px solid #000000;width: 178.50px;height: 264.67px">
<img alt="General loop has arrow to block 1 before decision and block 2 after decision; decision has 2 arrows out with true path leading to block 2 and false path leaving loop; arrow from block 2 loops back to block 1." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image3-1.png" style="width: 178.50px;height: 264.67px;margin-left: 0.00px;margin-top: 0.00px" width="178" height="257" class="alignnone" />
</span></p>
</td>
<td class="c8" colspan="1" rowspan="1">
<p class="c2"><span style="overflow: hidden;margin: 0.00px 0.00px;border: 0.00px solid #000000;width: 181.50px;height: 269.12px">
<img alt="While has arrow to decision (no block 1) with arrow to block 2 then arrow from block 2 loops back to decision." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image2-1.png" style="width: 181.50px;height: 269.12px;margin-left: 0.00px;margin-top: 0.00px" width="181" height="262" class="alignnone" />
</span></p>
</td>
<td class="c8" colspan="1" rowspan="1">
<p class="c2"><span style="overflow: hidden;margin: 0.00px 0.00px;border: 0.00px solid #000000;width: 190.99px;height: 276.44px">
<img alt="Do-while has has arrow to block 1 before decision (no block2). True output of decision box loops back to block 1." src="http://pressbooks.library.ryerson.ca/opsyshiraki/wp-content/uploads/sites/330/2022/03/image1-2.png" style="width: 190.99px;height: 276.44px;margin-left: 0.00px;margin-top: 0.00px" width="190" height="268" class="alignnone" />
</span></p>
</td>
</tr>
</tbody>
</table>
<p class="c21 c13 c9"><span class="c3"> </span></p>

</div>
<span>[h5p id="3"]</span>

<span>[h5p id="4"]</span>
<h1 id="h.v5u5941k43y1" class="c21 c4"><span class="c30">Loops in Unix</span></h1>
<p class="c6">There are three commands in Unix to support loops.</p>

<ul class="c14 lst-kix_r52uojy9d8wy-0 start">
 	<li class="c6 c15 li-bullet-0"><span class="c3">while</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">until        </span></li>
 	<li class="c6 c15 li-bullet-0">for</li>
</ul>
<h2 id="h.1g17zi2rpgp" class="c21 c4"><span class="c25">while command</span></h2>
<p class="c12"><span class="c3">The while command in Unix implements the General Loop construct discussed earlier.</span></p>
&nbsp;
<table class="grid">
<thead>
<tr class="c18">
<th class="c17" scope="col">
<p class="c12"><span class="c3">general syntax</span></p>
</th>
<th class="c17" scope="col">
<p class="c2"><span class="c11">relation to flow chart</span></p>
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<pre class="c12" style="margin-top: 1em"><span class="c0">while list1</span>
<span class="c0">do</span>
<span class="c0">  list2</span>
<span class="c26">done
</span></pre>
</td>
<td>
<pre id="h.4nau2ymu2e5j" class="c2 c20" style="margin-top: 1em"><span class="c0">while block1</span>
<span class="c0">      check</span>
<span class="c0">do</span>
<span class="c0">   block 2</span>
<span class="c0">done
</span></pre>
</td>
</tr>
</tbody>
</table>
<p class="c12">Unix runs the <span style="text-decoration: underline"><span class="c28">list1 </span></span>and looks at the return code ($?) of the <span class="c35">last command </span>in <span class="c28">list.</span>  (If there's only one command in the <span style="text-decoration: underline"><span class="c28">list1</span></span>, then that's the last command.)  If the return code of this last command is TRUE, then <span class="c28"><span style="text-decoration: underline">list2</span> </span>(loop body) is run.  Once the keyword "done" is reached, control returns to re-run <span class="c28"><span style="text-decoration: underline">list1</span> </span>and the return code of the last command in <span class="c28"><span style="text-decoration: underline">list1</span> </span><span class="c3">is checked.   If the return code of this last command is FALSE, then the while loop terminates, and control continues after the keyword "done".</span></p>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">E.g. 1: Count from 1 to 12</p>

</header>
<div class="textbox__content">
<pre class="c2 c13"><span class="c0">month=1                                </span>
<span class="c0">while echo Checking limit against month ${month}</span>
<span class="c26">  [ ${month} -le 12 ]   # The test is the last command in list1</span>
<span class="c0">do</span>
<span class="c26">   echo Performing action for month ${month}</span>
<span class="c26">   month=$(( ${month} + 1))</span>
<span class="c26">done</span><span class="c3"> 
echo Value of month outside loop is ${month}</span></pre>
<h3 class="c33 c4" id="h.mjqovltwcnos">Notes and observations</h3>
<ol class="c14 lst-kix_oax79x4ju1qf-0 start" start="1">
 	<li class="c12 c15 li-bullet-0"><span class="c3">The last command of list1 is a test command using the left bracket synonym.</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">The -le is a test command option for the numeric comparison less than or equal to.</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">As Unix program variables hold strings, to perform arithmetic operations, one must use the $(( .. )) syntax with dollar sign and double parentheses.</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">The formal spelling of Unix variables requires enclosure in set braces { }.  Where there is no ambiguity, it is common practice in Unix to omit the set braces.</span></li>
 	<li>Try running this code and see that the value of month never exceeds 12 in the line "echo Performing action ...".</li>
</ol>
</div>
</div>
&nbsp;
<h3 class="c7 c4" id="h.iodnffrfpn6n"><span class="c11">Preamble: Redirecting input from a file</span></h3>
<pre id="h.db51xr7z9zar" class="c2 c4 "><span class="c0">$ <strong>cat novel</strong></span>
<span class="c0">It was a</span>
<span class="c0">dark and</span>
<span class="c0">stormy</span>
<span class="c0">$ <strong>read oneline &lt; novel</strong></span>
<span class="c0">$ <strong>echo $oneline</strong></span>
<span class="c0">It was a</span>
<span class="c0">$ <strong>read oneline &lt; novel</strong></span>
<span class="c0">$ <strong>echo $oneline</strong></span>
<span class="c0">It was a</span>
<span class="c0">$</span></pre>
<p class="c5"><span class="c3"> </span></p>
<p class="c6">Be reminded that redirection operators in Unix (&lt;, &gt;, etc.) apply only to the current command.  Once the command is over, redirection is restored to the default configuration (STDIN from keyboard, STDOUT to screen, etc.).   Thus, observe that each time the read command is run, redirection is applied anew, and the first line of the file is read in.</p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Eg 2a: How to read every line of a file (a non-functional example)</p>

</header>
<div class="textbox__content" style="text-align: left">
<p class="c12">The objective is to read a file one line at a time.  Here is a newbie's first attempt.</p>
<p class="c12 c9"><span class="c3"> </span></p>

<pre id="h.cuirxscuuipk" class="c2 c4 "><span class="c0">$ <strong>cat badwhile</strong></span>
<span class="c0">while read wholeline &lt; novel</span>
<span class="c0">do</span>
<span class="c0">        something $wholeline         #e.g. echo $wholeline</span>
<span class="c0">done</span>
<span class="c0">$ <strong>./badwhile</strong></span>
<span class="c0">It was a</span>
<span class="c0">It was a</span>
<span class="c0">It was a</span>
<span class="c0">It was a</span>
...

<span class="c3">
</span><span class="c3"></span></pre>
What happened?  The redirection operator applies to the read command.  Each time the read command is run, redirection is applied anew and only the first line of the file is ever read.

&nbsp;

</div>
</div>
&nbsp;

How can one fix this problem?
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Eg 2b: How to read every line of a file? (a functional example)</p>

</header>
<div class="textbox__content">
<p class="c12"><span class="c3">To have redirection apply to the entire duration of the while loop and not just the read command, it is necessary to establish redirection and associate it with the while loop.</span></p>
<p class="c12"><span class="c3">Here is a template which you can use to read lines from a file one-at-a-time.</span></p>

<pre id="h.w0yrw0dvpa07" class="c2 c4 " style="padding-left: 40px"><span class="c0">while read wholeline</span>
<span class="c0">do</span>
<span class="c0">        something $wholeline  #e.g. echo $wholeline</span>
<span class="c0">done &lt; inputfile</span></pre>
<p class="c12"><span class="c3">To make this work, one must position the redirection operator after the command to which it should be applied.  The correct position is after the while command, in particular the keyword done.  Unix is smart enough to look ahead for redirection when it starts executing the while command.  Any commands within the while command which draw from STDIN (e.g. read) will draw from the redirected file. (If you are having difficulty understanding redirection, refer to the chapter on Redirection and Pipes.)</span></p>

</div>
</div>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Eg 3: How to process multiple command line arguments (Method 1)</p>

</header>
<div class="textbox__content">
<p class="c12">Recall that the cat command will accept <span class="c29">any </span><span class="c3">number of command line arguments like this: </span></p>

<pre class="c12" style="padding-left: 40px"><span class="c0">cat ch1 ch2 ch3 ...</span></pre>
<p class="c12">Let's say that you want to write your own Unix script that will accept any number of command line arguments<span class="c3">: </span></p>

<pre class="c12" style="padding-left: 40px"><span class="c26">mycmd parm1 parm2 ...</span></pre>
<p class="c12"><span class="c3">The key requirement here is that you will not know beforehand how many command-line arguments the user will supply when the user runs your program.  Your program must be flexible enough to handle zero or more command line arguments.</span></p>
<p class="c12"><span class="c3">Here is a template of code to solve this problem:</span></p>

<pre id="h.fu3ubjebea71" class="c2 c4 " style="padding-left: 40px"><span class="c0">while [ $1 ]</span>
<span class="c0">do</span>
<span class="c0">   someprocess $1</span>
<span class="c0">   shift</span>
<span class="c0">done</span></pre>
<p class="c12"><span class="c3">Explanatory notes:</span></p>

<ol class="c14 lst-kix_qkoa9ek4sumi-0 start" start="1">
 	<li class="c12 c15 li-bullet-0"><span class="c3">The last command in the while list is a test command (using the left square bracket synonym).</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">With no specific test operator (e.g. -r, etc.), the default behaviour of the test command is to check if the string is null.  The return code ($?) is TRUE for a non-null string (something is there), and FALSE for a null string.</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">The shift command slides all command line parameters to the left, in this case moving the next unprocessed command line argument into the $1 position.  (The shift command also has the side-effect of decrementing the $# variable.)</span></li>
 	<li class="c12 c15 li-bullet-0"><span class="c3">Once there are no more command line arguments, the loop terminates.  Note that if there were no command line arguments to begin with ($1 is NULL), the loop immediately terminates without entry into the body.  </span></li>
</ol>
</div>
</div>
&nbsp;
<div class="textbox textbox--exercises"><header class="textbox__header">
<p class="textbox__title">Exercise: Password entry loop</p>

</header>
<div class="textbox__content">
<p class="c6"><span class="c3">Write a bash script which will continually prompt a user to enter a password matching the control flow in the example below.  If the user enters the correct password, grant access.  If the user enters the wrong password, give the user another try (unlimited).  Avoid code duplication.</span></p>
<p class="c6"><span class="c3">Sample dialog:</span></p>

<pre id="h.f96okg636qf0" class="c6 c20 ">$ <strong><span class="c31">./whilecmdlist</span></strong>
What is the password? <strong><span class="c31">happy</span></strong>
<span class="c0">--- Sorry, that is not the right password.</span>
What is the password? <strong><span class="c31">access</span></strong>
<span class="c0">--- Sorry, that is not the right password.</span>
What is the password? <strong><span class="c31">Strawberry</span></strong>
<span class="c0">Welcome to the system.</span>
<span class="c0">$</span></pre>
</div>
</div>
<h2 id="h.ob9kkrkl6hkn" class="c21 c4"><span class="c25">until command</span></h2>
<p class="c12"><span class="c3">The until command in Unix implements the General Loop construct discussed earlier.</span></p>
<p class="c12"><span class="c3">The syntax is identical to the while command with the only difference that the logic of the conditional test is reversed.  If the last command in list1 is TRUE, the loop terminates.</span></p>
<p class="c12"><span class="c3">Here's the same explanation for the until command:</span></p>
<p class="c12">Unix runs the <span class="c28"><span style="text-decoration: underline">list1</span> </span>and looks at the return code ($?) of the <span class="c35">last command </span>in <span class="c28">list.</span>  (If there's only one command in the <span style="text-decoration: underline"><span class="c28">list1</span></span>, then that's the last command.)  If the return code of this last command is FALSE, then <span style="text-decoration: underline"><span class="c28">list2 </span></span>(loop body) is run.  Once the keyword "done" is reached, control returns to re-run <span style="text-decoration: underline"><span class="c28">list1 </span></span>and the return code of the last command in <span class="c28"><span style="text-decoration: underline">list1</span> </span><span class="c3">is checked.   If the return code of this last command is TRUE, then the until loop terminates, and control continues after the keyword "done".</span></p>

<h2 id="h.6jshw475ix66" class="c4 c24"><span class="c25">for command</span></h2>
<p class="c12"><span class="c3">The for command in Unix operates quite differently than what is common in other computer languages like BASIC or Pascal.  In particular, it is not a counted loop, rather one should think "iterative substitution".</span></p>

<div class="textbox">
<p class="c12"><span class="c3">Syntax:</span><span class="c3"> </span></p>

<pre id="h.ktj1na1jagj9" class="c2 c4" style="padding-left: 40px"><span class="c0">for name in word ...</span>
<span class="c0">do</span>
<span class="c0">   list</span>
<span class="c0">done</span></pre>
<p class="c12"><span class="c3">The list of words is expanded to create a list of items.  Each of these items is substituted into the variable name one-at-a-time and the list is run.</span></p>

</div>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">E.g. 1: Multiple file rename problem</p>

</header>
<div class="textbox__content">
<p class="c6"><span class="c3">Consider the problem of adding a suffix to several files.</span></p>
<p class="c6"><span class="c3">Those familiar with a DOS or Windows Power Shell environment could use a command like this:</span></p>

<pre id="h.wdrp2n6pkw9r" class="c2 c4" style="padding-left: 40px"><span class="c0">ren assig* assig*.bak</span></pre>
<p class="c6"><span class="c3">Unfortunately a similar command does not work in Unix:</span></p>

<pre id="h.hpp6ihrn25ql" class="c2 c4" style="padding-left: 40px"><span class="c0">mv assig* assig*.backup</span></pre>
<p class="c12"><span class="c3">Nevertheless, this problem can be solved with the simple use of a for command:</span></p>

<pre id="h.m89rbotpzgoo" class="c2 c4" style="padding-left: 40px"><span class="c0">for filevar in assig*</span>
<span class="c0">do</span>
<span class="c0">   mv ${filevar} ${filevar}.backup</span>
<span class="c0">done</span><span class="c3"> </span></pre>
<p class="c6"><span class="c3">Explanatory notes</span></p>

<ol class="c14 lst-kix_jxjz15y3u0r4-0 start" start="1">
 	<li class="c6 c15 li-bullet-0"><span class="c3">The word list is the wildcard file specification assig*.  On expansion, for the purposes of this example, assume that the result is three matching files: assig1, assig2, assig3.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Each of these words is substituted one-at-a-time in the loop variable filevar, and the body of the loop is run (code between do and done).</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">When the body of the loop is run with the variable substitutions, the effective commands generated are:</span></li>
</ol>
<ul class="c14 lst-kix_jxjz15y3u0r4-1 start">
 	<li id="h.dvkx6p67ti2p" class="c2 c4 c34 li-bullet-0">
<pre>mv assig1 assig1.backup</pre>
</li>
 	<li id="h.of4e4gyjmtnb" class="c2 c4 c34 li-bullet-0">
<pre>mv assig2 assig2.backup</pre>
</li>
 	<li id="h.v1za48sl0iwa" class="c2 c4 c34 li-bullet-0">
<pre>mv assig3 assig3.backup</pre>
</li>
</ul>
<p class="c6"><span class="c3">Additional Notes</span></p>

<ol class="c14 lst-kix_kt3z4gamf8jx-0 start" start="1">
 	<li class="c6 c15 li-bullet-0"><span class="c3">There is no specific string concatenation operator in Unix.  Simply placing text adjacently achieves the desired result.  Here the string ".backup" is appended to the "assig1", etc.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">As stated earlier, while the use of set braces { } is often omitted when spelling variables, here it helps to clarify the distinction between the variable name and surrounding text.</span></li>
</ol>
</div>
</div>
&nbsp;
<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">E.g. 2: Count the number of entries in a directory</p>

</header>
<div class="textbox__content">
<p class="c6"><span class="c3">Print the number of entries in the /etc directory.</span></p>

<pre id="h.sp9gj6lahn0n" class="c2 c4" style="padding-left: 40px"><span class="c0">cou</span><span class="c0">nt=0</span>
<span class="c0">for files in $(ls /etc)</span>
<span class="c0">do</span>
<span class="c0">   count=$(( $count +1 ))</span>
<span class="c0">done</span>
<span class="c0">echo The number of entries is $count</span><span class="c3"> </span></pre>
<p class="c6"><span class="c3">Explanatory notes</span></p>

<ol class="c14 lst-kix_qu9z8afik2yp-0 start" start="1">
 	<li class="c6 c15 li-bullet-0"><span class="c3">The word list consists of a command substitution call of the ls command on the /etc directory.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Expansion of this word list is the names of the entries in the /etc directory.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Each name is substituted into the loop variable files.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">The body of the loop consists of incrementing a counter which will eventually hold the number of entries.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Outside the loop, the total number of entries is printed in an appropriate message.</span></li>
</ol>
</div>
</div>
&nbsp;
<p class="c5"><span class="c3"> </span></p>

<div class="textbox textbox--examples"><header class="textbox__header">
<p class="textbox__title">Eg 3: How to process multiple command line arguments (Method 2)</p>

</header>
<div class="textbox__content">
<p class="c12"><span class="c3">Let's say that you want to write your own Unix script that will accept any number of command line arguments: </span></p>

<pre id="h.eb42c7begfsf" class="c2 c4" style="padding-left: 40px"><span class="c0">mycmd parm1 parm2 …</span></pre>
<p class="c6"><span class="c3">Here is another method, this one using the for command</span></p>

<pre id="h.8jw8rq3v95u2" class="c2 c4" style="padding-left: 40px"><span class="c0">for cmdarg in $*</span>
<span class="c0">do</span>
<span class="c0">        myprocess $cmdarg</span>
<span class="c0">done</span>
<span class="c3"> </span></pre>
<p class="c6"><span class="c3">Explanatory notes</span></p>

<ol class="c14 lst-kix_rnczc8u62bow-0 start" start="1">
 	<li class="c6 c15 li-bullet-0"><span class="c3">The special variable $* expands to all command line arguments present starting with $1.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Each of these words is substituted into the loop variable cmdarg.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">The body of the loop is run against each command line argument (myprocess is a fictitious Unix command or script).</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">Unlike the while command example, there is no need for the shift command.</span></li>
 	<li class="c6 c15 li-bullet-0"><span class="c3">The value of $# is intact after the completion of the for loop.</span></li>
</ol>
&nbsp;

</div>
</div>
<h2>break</h2>
The break statement causes control to exit the current for, while, or until loop.  One must be judicious in its use to avoid "spaghetti" code.  Except in rare circumstances, adherence to structure programming principles leads to clearer and less error-prone code. In many cases the use of break should be avoided.
<table class="grid" style="border-collapse: collapse;width: 100%;height: 45px" border="0">
<tbody>
<tr style="height: 15px">
<td style="width: 50%;height: 15px">
<h4>Poor (and rampant) use of break</h4>
</td>
<td style="width: 50%;height: 15px">
<h4>Better code</h4>
</td>
</tr>
<tr style="height: 15px">
<td style="width: 50%;height: 15px;vertical-align: top">
<pre>i=0
while true
do
  if [ $i -eq 5 ]
  then
    echo Reached 5
    <strong>break</strong>
  fi
  i=$(( $i + 1 ))
done</pre>
</td>
<td style="width: 50%;height: 15px;text-align: left;vertical-align: top">
<pre>i=0
while [ $i -ne 5 ]
do
  i=$(( $i + 1 ))
done
echo Reached 5</pre>
</td>
</tr>
<tr style="height: 15px">
<td style="width: 50%;height: 15px;vertical-align: top">
<h4>Observations</h4>
The use of an infinite loop (while true) is generally unnecessary (except perhaps in server processes) and should be avoided because it requires unstructured exit points leading to "spaghetti" code.  Here, the break statement is used to jump out midway through the loop contributing to poor program structure.

&nbsp;</td>
<td style="width: 50%;height: 15px;vertical-align: top">
<h4>Observations</h4>
The purpose and limit of the loop is coded clearly in the while condition.  Termination of the loop naturally follows coded instructions.  There is no jumping out from the middle of the loop.  The code is clearer, shorter, and better structured with a single entry and exit point for the loop.</td>
</tr>
</tbody>
</table>
&nbsp;

&nbsp;

&nbsp;

&nbsp;

&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>41</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:17]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2025-02-03 19:35:02]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2025-02-04 00:35:02]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[controlstruct2]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>6</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							</item>
					<item>
		<title><![CDATA[Quick Reference Guide]]></title>
		<link>https://pressbooks.library.torontomu.ca/opsyshiraki/chapter/quick-reference-guide/</link>
		<pubDate>Fri, 04 Mar 2022 20:11:17 +0000</pubDate>
		<dc:creator><![CDATA[swilson]]></dc:creator>
		<guid isPermaLink="false">https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/quick-reference-guide/</guid>
		<description></description>
		<content:encoded><![CDATA[<h1>Common Notations</h1>
Here are some commonly used but easy-to-forget notations and syntax.
<table class="grid" style="border-collapse: collapse;width: 100%" border="0">
<thead>
<tr>
<th style="width: 33.3333%;font-size: 1.2em" scope="col">Notation</th>
<th style="width: 33.3333%;font-size: 1.2em" scope="col">Typical usage with mini-example</th>
<th style="width: 33.3333%;font-size: 1.2em" scope="col">Where to get more info</th>
</tr>
</thead>
<tbody>
<tr>
<td style="width: 33.3333%">single quotes (')</td>
<td style="width: 33.3333%">Creates literal string protecting special characters.
<pre>grep 'Al Shaji' namelist</pre>
</td>
<td style="width: 33.3333%"><a href="https://pressbooks.library.ryerson.ca/opsyshiraki/chapter/shellvariables/">Shell Variables</a></td>
</tr>
<tr>
<td style="width: 33.3333%">double quotes (")</td>
<td style="width: 33.3333%">Like single quotes but interprets $, \ for variables.
<pre>echo "Price: $value"</pre>
</td>
<td style="width: 33.3333%"></td>
</tr>
<tr>
<td style="width: 33.3333%">$(cmd)</td>
<td style="width: 33.3333%">Command substitution.  Runs cmd and substitutes output of cmd at position of call.
<pre>today=$(date)</pre>
</td>
<td style="width: 33.3333%">man bash

&nbsp;</td>
</tr>
<tr>
<td style="width: 33.3333%">set braces { }</td>
<td style="width: 33.3333%">Formal variable specification; substrings.
<pre>echo ${alpha:3:5}</pre>
3 is offset (zero-based) and 5 is length</td>
<td style="width: 33.3333%"></td>
</tr>
<tr>
<td style="width: 33.3333%">double parentheses (( ))</td>
<td style="width: 33.3333%">Arithmetic expression.
<pre>a=$(( $a + 1 ))</pre>
</td>
<td style="width: 33.3333%">man bash</td>
</tr>
<tr>
<td style="width: 33.3333%">left square bracket [</td>
<td style="width: 33.3333%">Synonym for test command.
<pre>if [ $op = MR ]</pre>
Closing right bracket is needed.</td>
<td style="width: 33.3333%">man test</td>
</tr>
<tr>
<td style="width: 33.3333%">[[ string =~ regex ]]</td>
<td style="width: 33.3333%">Checks to see if regular expression (regex) is contained in string

Example

[[ importing =~ port ]] will return TRUE

Can be used with variables, too.

Example

[[ $title =~ $word ]] returns TRUE if $word is contained within $title</td>
<td style="width: 33.3333%">man bash</td>
</tr>
<tr>
<td style="width: 33.3333%">Character classes in regular expressions

[abc]</td>
<td style="width: 33.3333%">Square brackets represent a single character pattern.  Thus,

r[aou]n matches ran, ron, or run.

[Pp]olish matches Polish or polish</td>
<td style="width: 33.3333%">man regex.7

&nbsp;</td>
</tr>
</tbody>
</table>
<h1>FAQs</h1>
Q1a: How do make my script executable?

Q1b: I'm getting an error message, "-bash: ./myscript: Permission denied"

A1: You need to issue the chmod command, either:
<ul>
 	<li>
<pre>chmod 700 myscript</pre>
</li>
 	<li>
<pre>chmod u+x myscript</pre>
</li>
</ul>
&nbsp;]]></content:encoded>
		<excerpt:encoded><![CDATA[]]></excerpt:encoded>
		<wp:post_id>42</wp:post_id>
		<wp:post_date><![CDATA[2022-03-04 15:11:17]]></wp:post_date>
		<wp:post_date_gmt><![CDATA[2022-03-04 20:11:17]]></wp:post_date_gmt>
		<wp:post_modified><![CDATA[2022-10-07 16:50:57]]></wp:post_modified>
		<wp:post_modified_gmt><![CDATA[2022-10-07 20:50:57]]></wp:post_modified_gmt>
		<wp:comment_status><![CDATA[closed]]></wp:comment_status>
		<wp:ping_status><![CDATA[closed]]></wp:ping_status>
		<wp:post_name><![CDATA[quick-reference-guide]]></wp:post_name>
		<wp:status><![CDATA[publish]]></wp:status>
		<wp:post_parent>23</wp:post_parent>
		<wp:menu_order>7</wp:menu_order>
		<wp:post_type><![CDATA[chapter]]></wp:post_type>
		<wp:post_password><![CDATA[]]></wp:post_password>
		<wp:is_sticky>0</wp:is_sticky>
														<wp:postmeta>
		<wp:meta_key><![CDATA[pb_show_title]]></wp:meta_key>
		<wp:meta_value><![CDATA[on]]></wp:meta_value>
		</wp:postmeta>
							<wp:postmeta>
		<wp:meta_key><![CDATA[_edit_last]]></wp:meta_key>
		<wp:meta_value><![CDATA[335]]></wp:meta_value>
		</wp:postmeta>
							</item>
				</channel>
</rss>
	