<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.4.0">Jekyll</generator><link href="http://nathanbwright.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://nathanbwright.com/" rel="alternate" type="text/html" /><updated>2017-10-09T11:12:13-06:00</updated><id>http://nathanbwright.com/</id><title type="html">nathanbwright.com</title><subtitle>Various snippets that I have found to be helpful.
</subtitle><entry><title type="html">Set shell variable</title><link href="http://nathanbwright.com/shell/2016/09/08/set-shell-variable.html" rel="alternate" type="text/html" title="Set shell variable" /><published>2016-09-08T10:00:00-06:00</published><updated>2016-09-08T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/09/08/set-shell-variable</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/09/08/set-shell-variable.html">&lt;p&gt;To see what a shell variable is currently set to you can &lt;code class=&quot;highlighter-rouge&quot;&gt;echo&lt;/code&gt; it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$RAILS_ENV&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To set a shell variable you &lt;code class=&quot;highlighter-rouge&quot;&gt;export&lt;/code&gt; it.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;RAILS_ENV&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;production&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name></name></author><summary type="html">To see what a shell variable is currently set to you can echo it.</summary></entry><entry><title type="html">Find command</title><link href="http://nathanbwright.com/shell/2016/09/07/find-command.html" rel="alternate" type="text/html" title="Find command" /><published>2016-09-07T10:00:00-06:00</published><updated>2016-09-07T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/09/07/find-command</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/09/07/find-command.html">&lt;p&gt;Structure of a find command:&lt;/p&gt;

&lt;p&gt;find where-to-look criteria action&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;find . -name &lt;span class=&quot;s2&quot;&gt;&quot;*front*&quot;&lt;/span&gt; -print
&lt;span class=&quot;c&quot;&gt;#=&amp;gt; print out files that contain &quot;front&quot; in the current directory&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;find / -name foo.txt
&lt;span class=&quot;c&quot;&gt;#=&amp;gt; find a file called foo.txt from root&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To avoid permission denied use the following:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;find . ! -readable -prune -o -name &lt;span class=&quot;s1&quot;&gt;'*.txt'&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#=&amp;gt; find all readable .txt files from current directory&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name></name></author><summary type="html">Structure of a find command:</summary></entry><entry><title type="html">Copy things</title><link href="http://nathanbwright.com/shell/2016/05/15/copy-things.html" rel="alternate" type="text/html" title="Copy things" /><published>2016-05-15T10:00:00-06:00</published><updated>2016-05-15T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/05/15/copy-things</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/05/15/copy-things.html">&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;cp &lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;dest&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Some of the options for copying things.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cp -a&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Preserves structure and attributes of file but not directory structure, ie permissions, etc.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cp -i&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Interactive mode&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cp -R&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;If source file is a directory copy the directory and entire subtree - If the source file end in / copies the contents of the directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cp -v&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Verbose mode&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cp -n&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Do not overwrite an existing file&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;</content><author><name></name></author><summary type="html">$ cp source dest</summary></entry><entry><title type="html">Dealing with multiple jobs</title><link href="http://nathanbwright.com/shell/2016/04/12/dealing-with-multiple-jobs.html" rel="alternate" type="text/html" title="Dealing with multiple jobs" /><published>2016-04-12T10:00:00-06:00</published><updated>2016-04-12T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/12/dealing-with-multiple-jobs</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/12/dealing-with-multiple-jobs.html">&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;show all running processes&lt;/td&gt;
      &lt;td&gt;ps -f&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;search processes&lt;/td&gt;
      &lt;td&gt;pgrep nginx&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;kill process by id&lt;/td&gt;
      &lt;td&gt;kill pid&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;kill process by name&lt;/td&gt;
      &lt;td&gt;pkill sleep&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;kill all by name&lt;/td&gt;
      &lt;td&gt;killall sleep&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;force kill&lt;/td&gt;
      &lt;td&gt;kill -9 sleep&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;</content><author><name></name></author><summary type="html">show all running processes ps -f search processes pgrep nginx kill process by id kill pid kill process by name pkill sleep kill all by name killall sleep force kill kill -9 sleep</summary></entry><entry><title type="html">Show shell options</title><link href="http://nathanbwright.com/shell/2016/04/07/show-shell-options.html" rel="alternate" type="text/html" title="Show shell options" /><published>2016-04-07T10:00:00-06:00</published><updated>2016-04-07T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/07/show-shell-options</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/07/show-shell-options.html">&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; -o&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name></name></author><summary type="html">$ set -o</summary></entry><entry><title type="html">Shell redirection</title><link href="http://nathanbwright.com/shell/2016/04/07/shell-redirection.html" rel="alternate" type="text/html" title="Shell redirection" /><published>2016-04-07T10:00:00-06:00</published><updated>2016-04-07T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/07/shell-redirection</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/07/shell-redirection.html">&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Action&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Example usage&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&amp;gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Redirect standard output&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Write to file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&amp;gt;!&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Redirect standard output; overwrite file if it exists&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&amp;gt;&amp;amp;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Redirect standard output and standard error&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&amp;lt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Redirect standard input&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Read from file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;|&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Redirect standard output to another command (pipe)&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt; &lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&amp;gt;&amp;gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Append standard output&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Append to file&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Check out &lt;a href=&quot;http://sc.tamu.edu/help/general/unix/redirection.html&quot;&gt;sc.tamu.edu/help/general/unix/redirection.html&lt;/a&gt; for more info on redirection.&lt;/p&gt;</content><author><name></name></author><summary type="html">Command Action Example usage &amp;gt; Redirect standard output Write to file &amp;gt;! Redirect standard output; overwrite file if it exists   &amp;gt;&amp;amp; Redirect standard output and standard error   &amp;lt; Redirect standard input Read from file | Redirect standard output to another command (pipe)   &amp;gt;&amp;gt; Append standard output Append to file</summary></entry><entry><title type="html">Time command</title><link href="http://nathanbwright.com/shell/2016/04/06/time-command.html" rel="alternate" type="text/html" title="Time command" /><published>2016-04-06T10:00:00-06:00</published><updated>2016-04-06T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/06/time-command</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/06/time-command.html">&lt;p&gt;Prepend &lt;code class=&quot;highlighter-rouge&quot;&gt;time&lt;/code&gt; to a command to see how long it takes to run.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-shell&quot; data-lang=&quot;shell&quot;&gt;&lt;span class=&quot;gp&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;time &lt;/span&gt;sleep 12&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;</content><author><name></name></author><summary type="html">Prepend time to a command to see how long it takes to run.</summary></entry><entry><title type="html">Remove things</title><link href="http://nathanbwright.com/shell/2016/04/06/remove-things.html" rel="alternate" type="text/html" title="Remove things" /><published>2016-04-06T10:00:00-06:00</published><updated>2016-04-06T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/06/remove-things</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/06/remove-things.html">&lt;p&gt;Some of the options for removing things.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;rm -d&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Attempt to remove directories as well as other types of files.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;rm -f&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Attempt to remove file without prompting for confirmation. If file does not exist, do not display diagnostic message. The &lt;code class=&quot;highlighter-rouge&quot;&gt;-f&lt;/code&gt; option overrides any previous &lt;code class=&quot;highlighter-rouge&quot;&gt;-i&lt;/code&gt; options.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;rm -i&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Interactive mode&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;rm -R&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Attempt to remove the file hierarchy rooted in each file argument. The &lt;code class=&quot;highlighter-rouge&quot;&gt;-R&lt;/code&gt; option implies the &lt;code class=&quot;highlighter-rouge&quot;&gt;-d&lt;/code&gt; option.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;rm -v&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Verbose mode&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;</content><author><name></name></author><summary type="html">Some of the options for removing things.</summary></entry><entry><title type="html">List things</title><link href="http://nathanbwright.com/shell/2016/04/06/list-things.html" rel="alternate" type="text/html" title="List things" /><published>2016-04-06T10:00:00-06:00</published><updated>2016-04-06T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/06/list-things</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/06/list-things.html">&lt;p&gt;Some of the options for listing things.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -F&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Display directorys with a trailing / - an asterisk after each executable, etc&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -l&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;List in long format&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -lh&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Long list with human readible sizes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -t&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Sort by time modified&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -S&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Sort by size&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -r&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Reverse the order of sorting&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ls -R&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Recursively list subdirectories encountered&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;</content><author><name></name></author><summary type="html">Some of the options for listing things.</summary></entry><entry><title type="html">Disk usage</title><link href="http://nathanbwright.com/shell/2016/04/06/disk-usage.html" rel="alternate" type="text/html" title="Disk usage" /><published>2016-04-06T10:00:00-06:00</published><updated>2016-04-06T10:00:00-06:00</updated><id>http://nathanbwright.com/shell/2016/04/06/disk-usage</id><content type="html" xml:base="http://nathanbwright.com/shell/2016/04/06/disk-usage.html">&lt;p&gt;Some of the options for the &lt;code class=&quot;highlighter-rouge&quot;&gt;du&lt;/code&gt; command.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Command&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;du -a&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Display an entry for each file in a file hierarchy&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;du -s&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Display an entry for each specified file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;du -c&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Display a grand total&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;du -h&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Human readable&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;</content><author><name></name></author><summary type="html">Some of the options for the du command.</summary></entry></feed>