{"id":322647,"date":"2021-08-11T20:00:00","date_gmt":"2021-08-11T17:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-check-spelling-the-old-school-unix-way-cloudsavvy-it\/"},"modified":"2021-08-11T20:00:00","modified_gmt":"2021-08-11T17:00:00","slug":"how-to-check-spelling-the-old-school-unix-way-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-check-spelling-the-old-school-unix-way-cloudsavvy-it\/","title":{"rendered":"#How to Check Spelling the Old School Unix Way \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6af528609e383\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6af528609e383\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-check-spelling-the-old-school-unix-way-cloudsavvy-it\/#Checking_Spelling_On_The_Command_Line\" >Checking Spelling On The Command Line<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Check Spelling the Old School Unix Way \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage alignnone size-full wp-image-4038\" srcset=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=398&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 400w, https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1 1200w\" sizes=\"auto, 400w, 1200w\" src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Bash Shell\" width=\"1400\" height=\"600\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Before word processors had a spell check function, you had to run your own spell check against a document. And in the very early Unix days, systems didn\u2019t have a dedicated \u201cspell check\u201d program, but instead required a set of commands to do it yourself. Let\u2019s take a look at how to check spelling the \u201cold school Unix\u201d way.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Checking_Spelling_On_The_Command_Line\"><\/span>Checking Spelling On The Command Line<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>These days, we don\u2019t think about the spell checker in our word processor. You may not even \u201crun\u201d a spell check anymore. It\u2019s easier to watch for the red squiggly line to <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ear under misspelled words; if there\u2019s a red line under it, you fix the spelling.<\/p>\n<p>In the early Unix days, the system provided a dictionary file (usually <code>\/usr\/share\/dict\/words<\/code> on most Linux systems) that contained a sorted list of words from the dictionary, with each word on a line by itself. To check the spelling from a document, you need to compare all the words in your document against the dictionary file. And to do that, you need to convert your document into a format that looks like the dictionary file: a sorted list of words, with each word on its own line.<\/p>\n<p>The dictionary file is all lowercase, so first you need to convert your document to use lowercase letters. You do this with the <code>cat<\/code> command to display the file, and the <code>tr<\/code> command to translate characters from one set to another. In this case, you can ask <code>tr<\/code> to convert all the uppercase letters <strong>A-Z<\/strong> to the lowercase letters <strong>a-z<\/strong>:<\/p>\n<pre>cat document | tr A-Z a-z<\/pre>\n<p>While the dictionary includes in-word punctuation like hyphens and apostrophes, the list of words doesn\u2019t include sentence punctuation like periods and question marks. So the next step is to use <code>tr<\/code>, this time to delete (<code>-d<\/code>) the characters we don\u2019t want:<\/p>\n<pre>cat document | tr A-Z a-z | tr -d ',.:;()?!'<\/pre>\n<p>The dictionary file has each word on a line by itself, so you need to break your document up so each word appears on its own line. The <code>tr<\/code> command can replaces spaces with a \u201cnew line\u201d character, to do this for us:<\/p>\n<pre>cat document | tr A-Z a-z | tr -d ',.:;()?!' | tr ' ' 'n'<\/pre>\n<p>Sorting the output is easily done using the Unix <code>sort<\/code> command. Add the <code>uniq<\/code> command to clean up the output, to remove any duplicate words. For example, you probably use the word \u201cthe\u201d several times in any document. Using <code>sort<\/code> then <code>uniq<\/code> will s<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/trip-and-travel\/\" data-internallinksmanager029f6b8e52c=\"10\" title=\"Trip &amp; Travel\" target=\"_blank\" rel=\"noopener\">trip<\/a> out the repeated instances of \u201cthe\u201d so you only have one \u201cthe\u201d in your output.<\/p>\n<pre>cat document | tr A-Z a-z | tr -d ',.:;()?!' | tr ' ' 'n' | sort | uniq<\/pre>\n<p>Now you are ready to compare the list of words from your document with the dictionary file! The standard Unix command <code>comm<\/code> compares two files line-by-line, and identifies lines that are unique to the first file, unique to the second file, or lines that are common to both. To find the list of misspelled words from your document, you want the list of unique words \u2013 words that are found in your document, but not in the dictionary file. Use the <code>-2<\/code> option to <em>not<\/em> print the words unique to the second file, and the <code>-3<\/code> option to <em>not<\/em> display the words that are common to both files. What\u2019s left are the words unique to your document that do not appear in the dictionary; these are misspelled words.<\/p>\n<pre>cat document | tr A-Z a-z | tr -d ',.:;()?!' | tr ' ' 'n' | sort | uniq | comm -2 -3 - \/usr\/share\/dict\/words<\/pre>\n<p>The single hyphen tells <code>comm<\/code> to read from the \u201cstandard input,\u201d which is the output from the previous commands on the command line.<\/p>\n<p>And that\u2019s how to check spelling the \u201cold school Unix\u201d way! Let me demonstrate with a sample document. I\u2019ve intentionally misspelled a few words here:<\/p>\n<pre>$cat document&#13;\nEarly Unix didn't have word procesors like we thikn of them today. Instead,&#13;\nyou wrote a plain text document that might have embedded special commands to&#13;\nunderline text or create a list of bulet points. But how did you check the&#13;\nspelling of your document?<\/pre>\n<p>By running the list of commands, you\u2019ll find this list of misspelled words:<\/p>\n<pre>$cat document | tr A-Z a-z | tr -d ',.:;()?!' | tr ' ' 'n' | sort | uniq | comm -2 -3 - words&#13;\nbulet&#13;\nprocesors&#13;\nthikn<\/pre>\n<p>The key to checking spelling this way is the Unix <code>comm<\/code> command to compare two sorted lists of words. The two lists do need to be sorted the same way. Your Linux system\u2019s <code>\/usr\/share\/dict\/words<\/code> file may include some uppercase words such as common names or titles or locations. For example, the dictionary file on my Fedora 32 system contains both \u201cMinnesota\u201d (correct capitalization for the U.S. state name) \u201cminnesota\u201d (all lowercase) on adjacent lines. But the Unix <code>sort<\/code> command sorts uppercase letters separately from lowercase letters. This will confuse the <code>comm<\/code> command, which will complain the input file is not correctly sorted. To better match the \u201cold school Unix\u201d method to check spelling, you may first need to sort your system\u2019s dictionary file and save it in a separate file. You can do so like this:<\/p>\n<pre>sort \/usr\/share\/dict\/words &gt; words<\/pre>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/5439\/how-to-check-spelling-the-old-school-unix-way\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Check Spelling the Old School Unix Way \u2013 CloudSavvy IT&#8221; Before word processors had a spell check function, you had to run your own spell check against a document. And in the very early Unix days, systems didn\u2019t have a dedicated \u201cspell check\u201d program, but instead required a set of commands to do&#8230;<\/p>\n","protected":false},"author":1,"featured_media":322648,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-322647","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/322647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=322647"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/322647\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/322648"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=322647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=322647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=322647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}