<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7408278290683155292</id><updated>2024-10-05T03:00:23.117+01:00</updated><title type='text'>Do It With Linux</title><subtitle type='html'>A place for Linux tutorials, Linux Commands and lots of cool stuff to do with Linux!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-476272182859396455</id><published>2014-01-29T16:47:00.000+00:00</published><updated>2014-01-29T16:48:55.979+00:00</updated><title type='text'>What are Index Nodes?</title><content type='html'>I&#39;m writing about this because it came up as an issue while at work one day.&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;i&gt;&lt;u&gt;Background info!&lt;/u&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;Quite a while ago I wrote some software which keeps an eye on a number of servers and sends me an email if anything goes wrong, one of the things being if the servers hard disk becomes full / the system cannot create new files.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
So I&#39;m sat doing my daily java programming and I receive and email saying our main server is full, pretty strange because each server should have at least 20GB of space free at all times. So I log on to the system to see whats taking up all this room, the first command I do is &lt;span style=&quot;color: lime;&quot;&gt;df -h &lt;/span&gt;and I see the following output:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzTBoXHL32aOvhZYYNqPwdYJAfBPJPN52E8g5xGlHQLj-P2hYyfods5y6AkzNYJzZYaqxb-DYy_qC09DwGN7H9OfRNzDWWCxWcV1kSI9jxrM243nSjQyi5oRtGj8luoSLb-LfvV4IOQKPI/s1600/df.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzTBoXHL32aOvhZYYNqPwdYJAfBPJPN52E8g5xGlHQLj-P2hYyfods5y6AkzNYJzZYaqxb-DYy_qC09DwGN7H9OfRNzDWWCxWcV1kSI9jxrM243nSjQyi5oRtGj8luoSLb-LfvV4IOQKPI/s1600/df.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
This is not the output I expected, so I thought maybe there was a problem writing files to the disk so I run a &lt;span style=&quot;color: lime;&quot;&gt;touch text.txt&lt;/span&gt; command and this seems to run perfectly fine. After looking thought my email software to see if it had somehow made a mistake I get another email saying the server is having problems writing logs, this is when I start getting confused.&lt;br /&gt;
&lt;br /&gt;
I log back onto the system and check the logs. The logs had indeed stopped, as a test I wrote a small bash script to create a new file, it didn&#39;t work, instead it came back saying the hard disk was full.&lt;br /&gt;
&lt;br /&gt;
After some extreme head scratching and chin stoking I found the source of my problem by running the command &lt;span style=&quot;color: lime;&quot;&gt;df -i &lt;/span&gt;and seeing that my IUse% was 100%.&lt;br /&gt;
The problem was these strange little things called &#39;i-nodes&#39;.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Index Nodes (i-nodes)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
An index node is a data-structure used to represent a file system object, this can be disk block location, creation time and a whole host of other metadata. Each index node is roughly 128 bytes in size and all index nodes should really only ever take up 1% of your hard disk.
&lt;br /&gt;
&lt;br /&gt;
So for each file on your hard disk there is a i-node. So the solution presented itself, All I had to do was find the largest directory and backup and remove the files. To find the largest directory on the system I ran this command: &lt;span style=&quot;color: lime;&quot;&gt;du -a | sort -n -r&lt;/span&gt; and I instantly found the issue. Another developer had written a program which was producing a hell of a lot of log files, every 2 seconds a new log file (very small in size) was created. While this wasn&#39;t taking up much room on the hard drive it was taking up alot of index nodes.&lt;br /&gt;
&lt;br /&gt;
So there&#39;s a solution to anyone else having this issue.  
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/476272182859396455/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2014/01/what-are-index-nodes.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/476272182859396455'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/476272182859396455'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2014/01/what-are-index-nodes.html' title='What are Index Nodes?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzTBoXHL32aOvhZYYNqPwdYJAfBPJPN52E8g5xGlHQLj-P2hYyfods5y6AkzNYJzZYaqxb-DYy_qC09DwGN7H9OfRNzDWWCxWcV1kSI9jxrM243nSjQyi5oRtGj8luoSLb-LfvV4IOQKPI/s72-c/df.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-8711794497325586087</id><published>2013-11-15T15:01:00.004+00:00</published><updated>2013-11-15T15:03:13.047+00:00</updated><title type='text'>What The Hell is A Shell?!</title><content type='html'>I&#39;ve had a lot of people ask this question before, myself included. I thought I would write a small straight to the point post about the differences between the most common.
&lt;br /&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
I&#39;ll start by explaining exactly what a shell is and what it is used for. (Although most of you will probably already know)
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;What the hell is a shell?!&lt;/u&gt;&lt;/b&gt;
&lt;br /&gt;
Before graphical user interfaces the command line was the main interface for users, just like now where we have KDE, Gnome etc... the command line had shells. Shells were used to give the user a slightly different environment in terms of functionality and scripting. In technical terms a shell is a command line interpreter developed to make things easier for users. One example of this would be filename/command completion (do this by pressing tab after the first part of the command/filename). These small features that a lot of people see as part of linux is actully part of the shell. 
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Popular shells&lt;/u&gt;&lt;/b&gt;
&lt;br /&gt;
The most popular shell (and the shell most of you will probably be using) is the Bash Shell written by a guy called &lt;a href=&quot;http://en.wikipedia.org/wiki/Brian_Fox_(computer_programmer)&quot;&gt;Brian Fox&lt;/a&gt;. This is the most popular shell due to its robustness and tons of features. I use this shell at home all the time for scripting.
&lt;br /&gt;
&lt;br /&gt;
The Bourne Shell, AKA &#39;sh&#39;. This shell was developed by a guy called &lt;a href=&quot;http://en.wikipedia.org/wiki/Stephen_R._Bourne&quot;&gt;Stephen Bourne&lt;/a&gt;, It quickly became the default shell for Unix due to its support for variables, piping, looping and a verity of other usefull stuff. I use this shell mainly when writing software for embedded systems as it is the default shell.
&lt;br /&gt;
&lt;br /&gt;
The C-Shell AKA &#39;csh&#39; was developed by a guy called &lt;a href=&quot;http://en.wikipedia.org/wiki/Bill_Joy&quot;&gt;Bill Joy&lt;/a&gt;. This guy added useful things like aliases (short cuts for long commands) and command history. This shell was modeled on the C programming language, this was a good thing as Unix was written in C...although it did mean users of the bourne shell had to learn C in order to use the C-Shell.
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Which is the best shell?&lt;/u&gt;&lt;/b&gt;
&lt;br /&gt;
There are a large number of shells to choose from, I&#39;ve only named three here as these are the most popular. I would say the best shell is the Bash Shell due to how popular it is, this means most scripts written with this shell will most likely work on any machine. </content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/8711794497325586087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2013/11/what-hell-is-shell.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/8711794497325586087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/8711794497325586087'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2013/11/what-hell-is-shell.html' title='What The Hell is A Shell?!'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-2660016475065545509</id><published>2012-08-03T16:24:00.000+01:00</published><updated>2012-08-17T21:04:09.081+01:00</updated><title type='text'>Sed command examples</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A command I use&amp;nbsp;constantly&amp;nbsp;at work is the &#39;&lt;span style=&quot;color: lime;&quot;&gt;sed&lt;/span&gt;&#39;&amp;nbsp;command. This command is used when you want to make changes to a file automatically. Most people who use the &#39;&lt;span style=&quot;color: lime;&quot;&gt;sed&lt;/span&gt;&#39; command use it to replace text (which it does brilliantly) but there is so much more&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I&#39;m going to show you a few examples of the&amp;nbsp;awesomeness&amp;nbsp;of this command, if you have never used it before I&amp;nbsp;guaranty&amp;nbsp;you will use it after reading this post.&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Lets say we have a file which contains the following text:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&quot;This is my favourite place to learn about Linux. Linux is an opensource OS. Linux has a variety of different flavours.&quot;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Search and Replace&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Using the &#39;sed&#39; command we can search and replace. for example if I wanted to replace the word &#39;Linux&#39; with the word &#39;Unix&#39; I would do the following:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;

&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;
sed &#39;s/Linux/Unix/&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;

&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This would change the first&amp;nbsp;occurrence&amp;nbsp;of &quot;Linux&quot; to &quot;Unix&quot; as shown below:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&quot;This is my favourite place to learn about Unix. Linux is an opensource OS. Linux has a variety of different flavours.&quot;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Replacing the nth&amp;nbsp;occurrence&amp;nbsp;of a word is just as easy:
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;

&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;
sed &#39;s/Linux/Unix/2&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;


&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This will skip the first occurrence of &quot;Linux&quot; and replace the second one with &quot;Unix&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;favourite&amp;nbsp;place to learn about Linux. Unix is an opensource OS. Linux has a&amp;nbsp;variety&amp;nbsp;of&amp;nbsp;different&amp;nbsp;flavours.&lt;/i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If we would like to replace all occurrences of a word then we use the &quot;&lt;span style=&quot;color: lime;&quot;&gt;/g&lt;/span&gt;&quot; (Global) option:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;

&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;
sed &#39;s/Linux/Unix/g&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;

&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;All occurrences of the word &quot;Linux&quot; have now been replaced with &quot;Unix&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;favourite&amp;nbsp;place to learn about Unix. Unix is an opensource OS.&amp;nbsp;&lt;/i&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Unix&lt;/i&gt;&amp;nbsp;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;has a&amp;nbsp;variety&amp;nbsp;of&amp;nbsp;different&amp;nbsp;flavours.&lt;/i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;We can mess about with these options and merge them&amp;nbsp;together&amp;nbsp;to replace all occurrences of a word from a certain point, for example replacing all&amp;nbsp;occurrences&amp;nbsp;of the word &quot;Linux&quot; with the word &quot;Unix&quot; after the first&amp;nbsp;occurrence (the example below will make this a bit clearer):&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;sed &#39;s/Linux/Unix/2g&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;So after the second&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;occurrence the word &quot;Linux&quot; changes to &quot;Unix&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;Add a line after or before a match&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Here we can add a line after a match is found. For this we use the &quot;&lt;span style=&quot;color: lime;&quot;&gt;a&lt;/span&gt;&quot; command, for example:&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;sed &#39;/flavours/ a &quot;a new line!&quot;&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and the result is as follows:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;favourite&amp;nbsp;place to learn about Linux. Unix is an opensource OS. Linux has a&amp;nbsp;variety&amp;nbsp;of&amp;nbsp;different&amp;nbsp;flavours.&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;a new line!&lt;/i&gt;&quot;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The same thing can work adding a line before a match, we do this using the &quot;&lt;span style=&quot;color: lime;&quot;&gt;i&lt;/span&gt;&quot; command.&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;sed &#39;/flavours/ i &quot;a new line!&quot;&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and the result is as follows:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;favourite&amp;nbsp;place to learn about Linux. Unix is an opensource OS. Linux has a&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;a new line!&lt;/i&gt;&lt;br /&gt;
&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;variety&amp;nbsp;of&amp;nbsp;different&amp;nbsp;flavours.&lt;/i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;Replace a line&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;We can search for a match and then replace that whole line using the &#39;&lt;span style=&quot;color: lime;&quot;&gt;c&lt;/span&gt;&#39; command. It pretty much the same format as before:&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;sed &#39;/flavours/ c &quot;a replaced line!&quot;&#39; aFile.txt
&lt;/pre&gt;
&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and the result is as follows:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;favourite&amp;nbsp;place to learn about Linux. Unix is an opensource OS. Linux has a&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;a replaced line!&lt;/i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The last thing I&#39;m&amp;nbsp;going&amp;nbsp;to show you is the transform option. This is used to transform lower case letters to upper case letters. We use the &#39;&lt;span style=&quot;color: lime;&quot;&gt;y&lt;/span&gt;&#39; command for this. In this example I&#39;m going to change all the small l&#39;s and v&#39;s to large l&#39;s and v&#39;s, and vice versa:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;pre class=&quot;brush:bash&quot;&gt;sed &#39;y/lv/LV/ aFile.txt
&lt;/pre&gt;&lt;/span&gt;
&lt;span style=&quot;color: lime; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;
&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;&lt;i style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This&amp;nbsp;is my&amp;nbsp;faVourite&amp;nbsp;pLace to Learn about linux. Unix is an opensource OS. linux has a Variety&amp;nbsp;of&amp;nbsp;different&amp;nbsp;fLaVours.&lt;/i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&quot;&lt;/span&gt;

&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I hope this helps you guy&#39;s with the &#39;&lt;span style=&quot;color: lime;&quot;&gt;sed&lt;/span&gt;&#39; command, it can be very useful once you get to know it. Any questions are welcome.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/2660016475065545509/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/08/sed-command-examples.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2660016475065545509'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2660016475065545509'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/08/sed-command-examples.html' title='Sed command examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-5851395146081985777</id><published>2012-06-20T09:12:00.001+01:00</published><updated>2012-06-27T15:13:12.574+01:00</updated><title type='text'>How To Install Software On Linux (It&#39;s not that hard!)</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;OK, so I have had enough with people asking me how to install stuff on Linux, it&#39;s really not that difficult but it does seem to put a lot of people off the OS. I&#39;m going to go through a few things here such as rpm, tar.gz and tar.bz2.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;u&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;RPM&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;rpm stands for &quot;Red hat Package Manager&quot;. Files with this extension are installed and managed with the rpm program which I will take you through now.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The rpm program not only installs the software but it checks your system has all the&amp;nbsp;prerequisites. For example if you are trying to install a package called &quot;LinuxWow&quot; but that package requires &quot;LinuxFTW&quot; that you&amp;nbsp;haven&#39;t&amp;nbsp;installed rpm will not install &quot;LinuxWow&quot;. However if you have &quot;LinuxFTW&quot; then the package will be install as it should. This can save a lot of frustration...&amp;nbsp;believe&amp;nbsp;me. &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;before installing an rpm file it might be a good idea to check if you already have this installed, to do this run the&amp;nbsp;following&amp;nbsp;command:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;rpm -q&amp;nbsp;&lt;/span&gt;&lt;i style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;package_name&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;-q =&lt;/span&gt;&lt;span style=&quot;color: lime; font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;query&lt;/span&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The commands you would use to install, update or remove a .rpm file are as follows:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;Install one or multiple rpm files&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;rmp -ivh&lt;i&gt; packages1.rpm packages2.rpm&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;-i &lt;/span&gt;= install&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;-v &lt;/span&gt;=&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp;&lt;/span&gt;verbose information (additional info)&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;-h&lt;/span&gt; = Print 50 hash marks as the package archive is unpacked&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;u&gt;Update one or multiple rpm files&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;rpm -Fvh packages1.rpm packages2.rpm&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-style: italic;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-F &lt;/span&gt;= Freshen&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;Remove one or multiple rpm files&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;rmp -e packages1.rpm packages2.rpm&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;color: lime;&quot;&gt;-e&lt;/span&gt; = erase.&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: large;&quot;&gt;&lt;b&gt;&lt;u&gt;TAR.GZ &amp;amp; TAR.BZ2&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;tar files usually&amp;nbsp;contain&amp;nbsp;source code so the idea is that you compile (build) them yourself rather then relying on a program like rpm.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I&#39;ll show you how to install these files in 3 steps:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;1.&lt;/b&gt; First this is to list the packages in the file, this is to make sure we don&#39;t over right anything &amp;nbsp;precious on our system. We will use the &#39;&lt;span style=&quot;color: lime;&quot;&gt;less&lt;/span&gt;&#39; command for this. The &#39;&lt;span style=&quot;color: lime;&quot;&gt;|&lt;/span&gt;&#39; can be used as an extension of a command, so we could do &#39;&lt;span style=&quot;color: lime;&quot;&gt; | grep &quot;fileName&lt;/span&gt;&quot;&#39; if we wanted to grep the package for a certain file name.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;tar tvzf package.tar.gz | less&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;or&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;tar tvzf package.tar.bz2 | less&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-t &lt;/span&gt;= list, this is to list the contents of the package&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-v &lt;/span&gt;= verbose, you know this by now&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;-z &lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;= this filters the package through gzip, like&amp;nbsp;win-zip&amp;nbsp;if you&#39;re from windows&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-f = uses the package file&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;2.&lt;/b&gt; If we are happy with everything then we extract the files to a new directory, as shown below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;we make a new directory called newdir:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mkdir newdir&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Enter the directory:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;cd newdir&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;and extract the files:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;tar xvzf &amp;lt;path&amp;gt;/package.tar.gz&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;or&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;tar xvzf &amp;lt;path&amp;gt;/package.tar.bz2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;3.&lt;/b&gt; once extracted look for a file called &#39;install&#39; or &#39;readme&#39; these will give you the rest of the information you need. They usually tell you to run a script called &#39;&lt;span style=&quot;color: lime;&quot;&gt;configure&lt;/span&gt;&#39;, after that we run the &#39;&lt;span style=&quot;color: lime;&quot;&gt;make&lt;/span&gt;&#39;, (this will ask us to enter our root password) command and then finally the &#39;&lt;span style=&quot;color: lime;&quot;&gt;make install&lt;/span&gt;&#39;.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;./configure&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;make&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;su&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;(enter password)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;make install&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The &#39;readme&#39; file may contain some other information about the configure script which may require you adding some options but the file should give you all the information you need.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;It&#39;s really not that difficult to install software on a Linux machine. If you use Ubuntu like me then a simple &quot;apt-get install package&quot; would suffice. I hope this post makes people realise how easy it is.&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/5851395146081985777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/06/installing-software-its-not-that-hard.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/5851395146081985777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/5851395146081985777'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/06/installing-software-its-not-that-hard.html' title='How To Install Software On Linux (It&#39;s not that hard!)'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-7926296596602118821</id><published>2012-05-11T11:15:00.002+01:00</published><updated>2012-06-20T13:40:37.698+01:00</updated><title type='text'>Slightly more advanced guide to Shell Scripting</title><content type='html'>Hey guys,&lt;br /&gt;
&lt;div&gt;
In this post I hope to go through a few more advanced options when writing scripts. I&#39;m just going to cover things like methods,&amp;nbsp;parameters&amp;nbsp;and a few other tricks which can make your script look pretty cool.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;Methods&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
As a Java developer by trade I use methods quite a lot, programming without them is sort of odd, for those who don&#39;t know a &#39;method&#39; or &#39;function&#39; in basic terms is a section of code which can be called at a later time, you can probably see why this would be useful.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Say you have a menu system in your script where the user must&amp;nbsp;choose an option for the script to continue, each option would produce a&amp;nbsp;different&amp;nbsp;outcome, this is a good example of when you would want to use methods.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;Examples&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;***************EXAMPLE SCRIPT***************&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;Please choose and option:&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1 = &amp;nbsp;option A&quot;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2 =&amp;nbsp;
option B&amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3 =&amp;nbsp;
option C&amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;read option&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [[ &quot;$option&quot; == &quot;1&quot; ]]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONA&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [[ &quot;$option&quot; == &quot;2&quot; ]]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONB&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [[ &quot;$option&quot; == &quot;3&quot; ]]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONC&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;OPTIONA () {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Hello world, this is option A&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;OPTIONB () {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;echo &quot;Hello world, this is option B&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;OPTIONC () {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;echo &quot;Hello world, this is option C&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Ok so I&#39;m going to&amp;nbsp;dissect&amp;nbsp;this and explain what each part is doing, its quite simple really.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;***************EXAMPLE SCRIPT***************&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;Please choose and option:&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;1 = &amp;nbsp;option A&quot;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;2 =&amp;nbsp;&amp;nbsp;option B&amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;3 =&amp;nbsp;&amp;nbsp;option C&amp;nbsp;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
This part is the&amp;nbsp;actual&amp;nbsp;menu which will be shown to the user, we use the &#39;&lt;span style=&quot;color: lime;&quot;&gt;read option&lt;/span&gt;&#39; to read the input from the user and&amp;nbsp;assign&amp;nbsp;it to the&amp;nbsp;variable&amp;nbsp;&#39;&lt;span style=&quot;color: lime;&quot;&gt;option&lt;/span&gt;&#39;, this is so we can use it later in the if statements.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [ &quot;$option&quot; == &quot;1&quot; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONA&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [ &quot;$option&quot; == &quot;2&quot; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONB&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;if [ &quot;$option&quot; == &quot;3&quot; ]&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;OPTIONC&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp;exit 0&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;fi&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Here we have the if statements, quite straight forward really, what&#39;s happening is we are calling the &#39;&lt;span style=&quot;color: lime;&quot;&gt;option&lt;/span&gt;&#39;&amp;nbsp;variable, if this equals &#39;1&#39; for example then we call the &lt;span style=&quot;color: lime;&quot;&gt;OPTIONA&lt;/span&gt; method.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;OPTIONA () {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Hello world, this is option A&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
As you can see option A echo&#39;s out the line &lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp;&quot;Hello world, this is option A&quot;&lt;/span&gt;. After each method the code &#39;exit 0&#39; is run, this is just to exit the script cleanly.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;Parameters&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
A good example of&amp;nbsp;parameters&amp;nbsp;would be if you wanted to write a script to remove all &#39;.txt&#39; files from a directory. In order to do this you could write a script which takes in the directory path as a parameter. This makes the script more&amp;nbsp;flexible, it gives the user the choice of which directory input. The bash shell supports up to 9&amp;nbsp;parameters&amp;nbsp;which are represented in the script as &#39;&lt;span style=&quot;color: lime;&quot;&gt;$1&lt;/span&gt;&#39; (if you remember awk this might make more&amp;nbsp;sense) 1 being the number of the&amp;nbsp;parameter.&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;u&gt;Example&lt;/u&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;(cd $1 &amp;amp;&amp;amp; rm *.txt)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
This is a very simple example, to run this script (lets call it &lt;span style=&quot;color: lime;&quot;&gt;remove.sh&lt;/span&gt;) you would do the following:&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;./remove.sh /home/zdrenka/pictures&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The script would then assign &#39;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: lime;&quot;&gt;/home/zdrenka/pictures&lt;/span&gt;&#39; to &#39;&lt;span style=&quot;color: lime;&quot;&gt;$1&lt;/span&gt;&#39; and&amp;nbsp;that&#39;s&amp;nbsp;what we call a&amp;nbsp;parameter, there are loads of useful ways in which to use this&amp;nbsp;facility.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Since I started scripting I have picked up bits and bobs which can make your script look pretty cool, one of which is colours. Colours can make a script look that little bit more impressive. When I write a script one of the first things I do is paste this at the top:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;################################################&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;# Define colours&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;################################################&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtund=$(tput sgr 0 1) &amp;nbsp; &amp;nbsp;# Underline&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtbld=$(tput bold) &amp;nbsp; &amp;nbsp; &amp;nbsp; # Bold&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtred=$(tput setaf 1) &amp;nbsp; &amp;nbsp;# Red&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtgrn=$(tput setaf 2) &amp;nbsp; &amp;nbsp;# Green&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtylw=$(tput setaf 3) &amp;nbsp; &amp;nbsp;# Yellow&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtblu=$(tput setaf 4) &amp;nbsp; &amp;nbsp;# Blue&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtpur=$(tput setaf 5) &amp;nbsp; &amp;nbsp;# Purple&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtcyn=$(tput setaf 6) &amp;nbsp; &amp;nbsp;# Cyan&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtwht=$(tput setaf 7) &amp;nbsp; &amp;nbsp;# White&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;txtrst=$(tput sgr0) # Text reset&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
the &#39;&lt;span style=&quot;color: lime;&quot;&gt;#&lt;/span&gt;&#39; are obviously comments. I wrote this a while ago and now have it saved as a template, I use the colours to highlight errors, its very&amp;nbsp;useful&amp;nbsp;when you have a lot of text on the screen. to use these colours we just add them to the text as shown below:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;echo &quot;${txtbld}${txtred}ERROR File does not exist ${txtrst}&quot;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The &#39;txtrst&#39; variable will reset the text back to its original colour, you need this otherwise all text below your statement will be red.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Another useful command I have come&amp;nbsp;across&amp;nbsp;is the &#39;&lt;span style=&quot;color: lime;&quot;&gt;set -e&lt;/span&gt;&#39; command. Put this at the top of your script and the script will automatically quit if it comes across and error, this is good practise as if you hit an error its not&amp;nbsp;usually&amp;nbsp;a good idea to carry on with the script. Although if you would like to have this command skip a certain part of the code you can surround that part with &#39;&lt;span style=&quot;color: lime;&quot;&gt;set +e&lt;/span&gt;&#39; and &#39;&lt;span style=&quot;color: lime;&quot;&gt;set -e&lt;/span&gt;&#39;. for example:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;set +e&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;cp *.txt *.jar *.war /home/zdrenka/Java&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: lime;&quot;&gt;set -e&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Without these my script would stop once it hit this &lt;span style=&quot;color: lime;&quot;&gt;cp&lt;/span&gt; command as there may not be any &#39;&lt;span style=&quot;color: lime;&quot;&gt;.war&lt;/span&gt;&#39;, &#39;&lt;span style=&quot;color: lime;&quot;&gt;.txt&lt;/span&gt;&#39; or &#39;&lt;span style=&quot;color: lime;&quot;&gt;.jar&lt;/span&gt;&#39; files in my&amp;nbsp;Java&amp;nbsp;directory which would technically throw up an error.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I hope this quenches your thirst for knowledge, I&#39;ll put more posts on soon!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/7926296596602118821/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/05/slightly-more-advanced-guide-to-shell.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7926296596602118821'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7926296596602118821'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/05/slightly-more-advanced-guide-to-shell.html' title='Slightly more advanced guide to Shell Scripting'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-1166617258065243036</id><published>2012-04-12T20:13:00.002+01:00</published><updated>2012-04-18T13:17:53.169+01:00</updated><title type='text'></title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;a href=&quot;http://doitwithlinux.blogspot.co.uk/p/fun-linux-commands.html&quot;&gt;SCP Command Examples&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Make a secure copy of this page guys!&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/1166617258065243036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/04/scp-command-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/1166617258065243036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/1166617258065243036'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/04/scp-command-examples.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-7417830371763128467</id><published>2012-03-18T17:12:00.003+00:00</published><updated>2012-04-19T15:21:14.484+01:00</updated><title type='text'></title><content type='html'>&lt;b&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;a href=&quot;http://doitwithlinux.blogspot.co.uk/p/netcat-command-examples.html&quot;&gt;Netcat Command Examples&lt;/a&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Netcat is out the bag!</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/7417830371763128467/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/netcat-command-examples-now-be-good.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7417830371763128467'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7417830371763128467'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/netcat-command-examples-now-be-good.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-7910079218007236318</id><published>2012-03-13T11:37:00.001+00:00</published><updated>2012-06-20T13:51:35.180+01:00</updated><title type='text'>Mplayer Command Examples</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;mplayer is a media player, its mainly used to play audio or video.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;What I like about it is how you can use it in the command line.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For example to play a audio file.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;maplyer mediafile.mp3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Its as simple as that.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;For a video its slightly differnt. Mplayer does not support dvd menu&#39;s which is a bit of a pain really so you need to do the following&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mplayer dvd://titlenumber&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;obviously titlenumber needs to be replaced with your desired title number. Xine is a lot better for DVD menu&#39;s but thats a whole other kettle of fish&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;If you wish to move forward in a track or film there a a whole load of keyboard short cuts avalible here&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I know your thinking &quot;whats the big deal?&quot; but the real reason I use mplayer is to rip audio from video files.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I use this a lot in conjunction with the youtube-dl program.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile someVideo nameOfAudioFile.mp3&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I&#39;ve taken the liberty off adding a selection of commands below:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;Play all files in directory&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;$mplayer -playlist &amp;lt;(find &quot;$PWD&quot; -type f)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;Stream Youtube directly to mplayer&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;$yt () mplayer -fs -quiet $(youtube-dl -g &quot;$1&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;Create an animated gif of a youtube video&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;url=http://www.youtube.com/watch?v=V5bYDhZBFLA; youtube-dl -b $url; mplayer $(ls ${url##*=}*| tail -n1) -ss 00:57 -endpos 10 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;use mplayer to play just the audio from a video&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mplayer -vo null something.mpg&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;u&gt;Shuffle songs in mplayer with no output&lt;/u&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mplayer -shuffle $HOME/music/* $HOME/Dropbox/Music/*/* $HOME/Dropbox/Music/*/*/* etc. &amp;gt;&amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/7910079218007236318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/mplayer-command-examples-make-your.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7910079218007236318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7910079218007236318'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/mplayer-command-examples-make-your.html' title='Mplayer Command Examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-2608792244512189662</id><published>2012-03-06T20:18:00.001+00:00</published><updated>2012-06-20T13:50:09.143+01:00</updated><title type='text'>Mail Command Examples</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mail [-t] [-w] [ -m message_type ] recipient&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The Mail Command is a good way (not the only way) of sending/receiving&amp;nbsp;emails via the console.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Root is required for this:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mail someone@somewhere.com&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This command will set up the email, it will then ask you for a subject, CC&#39;s and message.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;once your done&amp;nbsp;&lt;span style=&quot;background-color: white; color: #111111; font-size: 14px; line-height: 22px;&quot;&gt;You need to type . (dot) to send the email.&lt;/span&gt;&amp;nbsp;Then Enter.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;It&#39;s better if you use the following command:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mail -s &quot;subject&quot;&amp;nbsp;too@somewhere.com -- -r &quot;from@somewhere.com&quot; -f &amp;lt;/path/to/a/file&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This command will send an email with a subject to an address from the address specified, the&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-f &amp;lt;/path/to/a/file&amp;gt;&lt;/span&gt;&amp;nbsp;is the file which contains the information,in my case an error log.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;this can be&amp;nbsp;shorted&amp;nbsp;to:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;mail -s &quot;subject&quot; someguy@someplace.com &amp;lt; atextfile.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I often find myself using this command instead, its quicker to type...I should really make a script to do all this for me.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;More posts coming, and scripts!&lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/2608792244512189662/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/mail-command-examples-youve-got-mail.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2608792244512189662'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2608792244512189662'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/mail-command-examples-youve-got-mail.html' title='Mail Command Examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-2839530132647577339</id><published>2012-03-06T10:07:00.001+00:00</published><updated>2012-06-20T13:49:35.062+01:00</updated><title type='text'>My Top 5 SSH Commands</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;text-align: center;&quot;&gt;SSH(Secure Shell) is a network protocol for secure data communication, unlike Telnet SSH connects via a secure&amp;nbsp;channel over an&amp;nbsp;insecure&amp;nbsp;network.&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; text-align: center;&quot;&gt;This means that data sent over SSH is&amp;nbsp;encrypted.&lt;/span&gt;&lt;br /&gt;
Below I have added some useful commands for using SSH, Have Fun :)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;ssh -t reachable_pc ssh unreachable_pc&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I&#39;ve had the problem where I need to connect to my PC at work, unfortunately&lt;br /&gt;
the ip address is unreachable, but it is reachable from the server at work.&lt;br /&gt;
Operation SSH man-in-the-middle is in effect!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;ssh user@host cat /path/to/a/text/file | xclip&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is good for copying a file to your work machine and having it sit&lt;br /&gt;
in your X11 buffer (clipboard) so then just right click and paste contents of the file&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;ssh-copy-id user@host&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is very handy if you need to connect to a large number of hosts&lt;br /&gt;
it copys the SSH keys thus giving you password-less logins :D!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;dd if=/dev/dsp | ssh -c arcfour -C username@host dd of=/dev/dsp&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
This is a strange one but kinda fun, I found this through google so its not mine&lt;br /&gt;
this will output the sound from you microphone to a remote computers speakers via SSH&lt;br /&gt;
funky eh?!&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime;&quot;&gt;ssh -N -L2005:localhost:80 remotehost&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
One of the best things about SSH is&amp;nbsp;Tunnelling, with the above command you can&lt;br /&gt;
view a remote hosts current website by going to http://localhost:2005&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/2839530132647577339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/my-top-5-ssh-commands-this-is-just.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2839530132647577339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2839530132647577339'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/my-top-5-ssh-commands-this-is-just.html' title='My Top 5 SSH Commands'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-2410518854318122521</id><published>2012-03-04T15:29:00.003+00:00</published><updated>2012-06-20T13:48:26.906+01:00</updated><title type='text'>Beginners&#39; Guide to Shell Scripting</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;It has come to my attention that a lot of people need a beginners&#39; guide to shell scripting, therefore I am obliged to provide one.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This tutorial will provide a grounding for shell scripting.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Shell scripting in Linux isn&#39;t to difficult to master, although it helps if you have some programming background. We&#39;ll start by explaining the shell.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;The shell&lt;/b&gt;&amp;nbsp;is a program which actually processes commands and returns output. Bash is the most popular Linux shell as it contains standard features such as foreground and background processes and command history.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;A question that is asked a lot is: &quot;&lt;span style=&quot;font-style: italic;&quot;&gt;what&#39;s the difference between the Console and the Terminal?&lt;/span&gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;The Terminal&lt;/b&gt;&amp;nbsp;is a wrapper program which runs a shell. This was once a physical device which consisted of not much more then a monitor and keyboard. As time moved on this became software and can be used to access the shell and run commands.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;The Console&lt;/b&gt;&amp;nbsp;is a special kind of Terminal, the Console used to be used for low level communication with the operating system. These days it is used in much of the same way as the Terminal.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;In conclusion there isn&#39;t really much difference between the two, they both have separate pasts but are now essentially used for the same thing.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Writing Scripts&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;I recommend using&amp;nbsp;&lt;a href=&quot;http://projects.gnome.org/gedit/&quot;&gt;gedit&lt;/a&gt;&amp;nbsp;to write your scripts as it has a lot of great tools to make use of, although if you are unfortunate enough to be using a Windows system I recommend&amp;nbsp;&lt;a href=&quot;http://notepad-plus-plus.org/download/v5.9.8.html&quot;&gt;Notepad++&lt;/a&gt;&amp;nbsp;(I use this at work to write scripts and it&#39;s very similar to gedit).&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;At the top of each script the we have a Shebang line. &amp;nbsp;It consists of a number sign and an exclamation point character (#!), followed by the full path to the interpreter such as /bin/bash. All scripts under UNIX and Linux execute using the interpreter specified on a first line. Then we would have the command we wish to execute.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;echo Hello Linux!&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The above script when run will display the words &quot;Hello Linux&quot; in the console/terminal. It uses the echo command which does what it says on the tin, it will echo out the&amp;nbsp;words Hello Linux!.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This is one way of doing it, however the use of variables is more elegant. A variable stores data in memory and can be called at differnt times within the script, it can also be changed and&amp;nbsp;amended throughout the script. Below is an example of Hello Linux with variables.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span lang=&quot;en-US&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;
&lt;span lang=&quot;en-US&quot;&gt;&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;VAR=&quot;Hello Linux!”&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;
&lt;span lang=&quot;en-US&quot;&gt;&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;echo $VAR&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0in; margin-right: 0in; margin-top: 0in;&quot;&gt;
&lt;span lang=&quot;en-US&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Next we must learn how to use the chmod command, this is use to set the permissions for the script we have just created.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;Chmod&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the chmod command (&lt;span style=&quot;color: lime;&quot;&gt;ch&lt;/span&gt;ange&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;mod&lt;/span&gt;e) is a command that lets the user control how much access it should permit to a file. In order to run our script we must first use chmod to make it executable &amp;nbsp;to do this I use the command&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;chmod +x helloLinux.sh&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;+x&lt;/span&gt;&amp;nbsp;makes the scipt executable for ALL users, if you just want it to be exe for you then&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;u+x&lt;/span&gt;&amp;nbsp;is for you.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;After this command a simple ./&lt;span lang=&quot;en-US&quot;&gt;helloLinux.sh&lt;/span&gt;&amp;nbsp;will run the script.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Hopefully this should give you a good grounding for writing your own shell scripts.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Any questions are welcome!&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/2410518854318122521/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/beginners-guide-to-shell-scripting-live.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2410518854318122521'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/2410518854318122521'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/beginners-guide-to-shell-scripting-live.html' title='Beginners&#39; Guide to Shell Scripting'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-1337418429209752829</id><published>2012-03-01T10:03:00.000+00:00</published><updated>2012-06-20T13:50:52.089+01:00</updated><title type='text'>Grep Command Examples</title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;grep [options] PATTERN [FILE...]&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The grep command basicaly searches though a file for lines which match the given pattern&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, sans-serif;&quot;&gt;, for example:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;grep apple fruit.txt&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;this will output all lines which contain the word apple, its as easy as that!&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;You could also specify a search in more then one file with the &#39;&lt;span style=&quot;color: lime;&quot;&gt;*&lt;/span&gt;&#39; wildcard&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;grep apple *.txt&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;like all good commands grep lets you use regular expressions such as the following:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;grep ^a fruit.txt&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the above line will return all lines which begin with the letter a.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;Once you get the hang of grep you can do some pretty cool things, heres a command which I use a lot (provided by Sean, he know&#39;s who he is), it looks&lt;br /&gt;complicated but I&#39;ll break it down:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;grep --color=always -niC number &quot;string&quot; filename | less -R&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;--color=always&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;this colours the pattern to make it jump out at you when searching&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;-niC&lt;/span&gt;n would be the line number, this isnt always needed so it can be removed.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&#39;&lt;span style=&quot;color: lime;&quot;&gt;i&lt;/span&gt;&#39; is to match both upper and lowercase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&#39;&lt;span style=&quot;color: lime;&quot;&gt;C&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;number&lt;/span&gt;&#39; is the number of lines surrounding the matchs you want to show, the alternative is&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;A&lt;/span&gt;&amp;nbsp;and&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;B&lt;/span&gt;&amp;nbsp;which is to show lines before or after the match&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;&quot;string&quot;&lt;/span&gt;&amp;nbsp;is the pattern, but then you already knew that ;)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;filename is the file you are searching, you can use the &#39;&lt;span style=&quot;color: lime;&quot;&gt;*&lt;/span&gt;&#39; wildcard as mentioned above or you can type another file name next to it which will also work&lt;br /&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;| less -R&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;this is the pipe that lets you scroll down the output of the search, the&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;-R&lt;/span&gt;&amp;nbsp;is the necessary command to let the color work with the scrolling&lt;br /&gt;basiccaly this makes it easier to read.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;you can also save the ouput as a txt file by using&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp;| tee output.txt&lt;/span&gt;&amp;nbsp;and appending it to the end of the grep command, the cool thing&amp;nbsp; is that the color stays in the output.txt!&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial;&quot;&gt;There are loads of useful switches to use with grep try &#39;&lt;span style=&quot;color: lime;&quot;&gt;man&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: lime;&quot;&gt;grep&lt;/span&gt;&#39; in the console&lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/1337418429209752829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/grep.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/1337418429209752829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/1337418429209752829'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/03/grep.html' title='Grep Command Examples'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-5632655645003790474</id><published>2012-02-29T11:46:00.002+00:00</published><updated>2012-03-06T10:10:21.797+00:00</updated><title type='text'></title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;&lt;a href=&quot;http://doitwithlinux.blogspot.com/p/awk-command-examples.html&quot;&gt;&lt;b&gt;Awk Command Examples&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;awk can be a bit tricky but&amp;nbsp;hopefully&amp;nbsp;this will give you a good idea of its&amp;nbsp;functionality.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/5632655645003790474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/awk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/5632655645003790474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/5632655645003790474'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/awk.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-924381653953469637</id><published>2012-02-28T12:51:00.002+00:00</published><updated>2012-03-13T13:04:34.317+00:00</updated><title type='text'></title><content type='html'>&lt;a href=&quot;http://doitwithlinux.blogspot.com/p/cron-examples.html&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;&lt;b&gt;Cron Examples&lt;/b&gt;&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Cron is somthing I find most useful, its&amp;nbsp;definitely&amp;nbsp;worth learning about.&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/924381653953469637/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/cron-crontab_28.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/924381653953469637'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/924381653953469637'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/cron-crontab_28.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-7283044429825112601</id><published>2012-02-28T10:42:00.003+00:00</published><updated>2012-06-20T13:45:49.336+01:00</updated><title type='text'></title><content type='html'>&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;The &#39;&lt;span style=&quot;color: lime;&quot;&gt;at&lt;/span&gt;&#39; command basically executes a command at a specified time, surprisingly useful if you need to print something at 3pm and you&#39;re useless at remembering stuff..&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;The Below command will run the jobtodo script at 15:00&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;at -m 15:00 &amp;lt; jobtodo.sh&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: lime;&quot;&gt;at -l&lt;/span&gt;&lt;/b&gt;&amp;nbsp;- this will list all jobs scheduled&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: lime;&quot;&gt;atrm 3&lt;/span&gt;&lt;/b&gt;&amp;nbsp;- this will remove job 3 from the list&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;To be honest if you want something that will run every day your better off looking at crontab. But if you after something quick and simple this will do just nicely. I use this command at work for running scripts at set times of the day, that way I wont forget.&lt;/span&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/7283044429825112601/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/at-command_28.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7283044429825112601'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/7283044429825112601'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/at-command_28.html' title=''/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7408278290683155292.post-3517769276234566171</id><published>2012-02-27T18:59:00.002+00:00</published><updated>2012-06-20T13:47:13.433+01:00</updated><title type='text'>Download BBC shows on Linux with get_Iplayer</title><content type='html'>&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: x-large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;get_Iplayer is an easy way to download tv and radio from the bbc iplayer website.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;get_iplayer can be downloaded from linuxcentre.net&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;the below command can be used to download TV or radio given the correct link.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: lime;&quot;&gt;sudo get_iplayer --get --type&lt;/span&gt;&amp;nbsp;&lt;i&gt;&amp;lt;type&amp;gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;&amp;nbsp;--url=&lt;/span&gt;&lt;i&gt;&amp;lt;url&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;type&amp;gt;&lt;/i&gt;&amp;nbsp;- the type will either be &#39;tv&#39; or &#39;radio&#39; depending on what you wish to download.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;url&amp;gt;&lt;/i&gt;&amp;nbsp;- to get the url its best if you click &#39;Link to this&#39; button on Iplayer website.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;This has been very useful for me as I&#39;m constantly missing my favorite shows. Below I have added a very simple script:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;echo &quot;tv or radio?&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;read option&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;echo &quot;PLease paste in you link for the content you wish to download:&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;read url&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;get_iplayer --get --type $option --url=$url&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, sans-serif;&quot;&gt;this can be adapted to make a series link. I suggest looking into &#39;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;crontab&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&#39; or the &#39;&lt;/span&gt;&lt;span style=&quot;background-color: white; color: lime; font-family: Arial, Helvetica, sans-serif;&quot;&gt;at&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Arial, Helvetica, sans-serif;&quot;&gt;&#39; command&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://doitwithlinux.blogspot.com/feeds/3517769276234566171/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/getiplayer.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/3517769276234566171'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7408278290683155292/posts/default/3517769276234566171'/><link rel='alternate' type='text/html' href='http://doitwithlinux.blogspot.com/2012/02/getiplayer.html' title='Download BBC shows on Linux with get_Iplayer'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03631013823036663113</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>