<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Six useful shell commands for web developers</title>
	<atom:link href="http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/feed/" rel="self" type="application/rss+xml" />
	<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/</link>
	<description>the personal blog of Stuart Colville covering modern web development techniques and best practices</description>
	<pubDate>Thu, 20 Nov 2008 12:19:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Nolan Clayton</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-30287</link>
		<dc:creator>Nolan Clayton</dc:creator>
		<pubDate>Thu, 08 Mar 2007 16:22:47 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-30287</guid>
		<description>The Recursive Grep

alias rgrep 'find . -name \!:2 &#124; xargs grep -i \!:1 &#124; grep -v .svn &#124; grep -v "~"'

Example Usage
rgrep "whatever" "*"
rgrep "print" "*.xml" &#124; less</description>
		<content:encoded><![CDATA[<p>The Recursive Grep</p>
<p>alias rgrep &#8216;find . -name \!:2 | xargs grep -i \!:1 | grep -v .svn | grep -v &#8220;~&#8221;&#8216;</p>
<p>Example Usage<br />
rgrep &#8220;whatever&#8221; &#8220;*&#8221;<br />
rgrep &#8220;print&#8221; &#8220;*.xml&#8221; | less</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-24019</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Mon, 29 Jan 2007 09:22:43 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-24019</guid>
		<description>@jey: If you're referring to rsync if you attempt to rsync between different servers uptodate versions of rsync will use ssh by default.

If this is a problem try &lt;code&gt;rsync -e ssh&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>@jey: If you&#8217;re referring to rsync if you attempt to rsync between different servers uptodate versions of rsync will use ssh by default.</p>
<p>If this is a problem try <code>rsync -e ssh</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jey</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-23989</link>
		<dc:creator>jey</dc:creator>
		<pubDate>Mon, 29 Jan 2007 05:45:48 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-23989</guid>
		<description>could anyone tell me the way to use back-up command in ssh?</description>
		<content:encoded><![CDATA[<p>could anyone tell me the way to use back-up command in ssh?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chrisb</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-13178</link>
		<dc:creator>chrisb</dc:creator>
		<pubDate>Wed, 25 Oct 2006 21:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-13178</guid>
		<description>Another good one from today: I am transitioning to the new mediatemple grid server (highly recommended), and I have an old apache httpd.conf file with LOTS of old dead Virtual host directives sites on my current server. So there is no need to move them.

Could have used something like http://www.dnsstuff.com/ (also recommended) to manually look up each url, but instead i just created a list of the addresses called "siteslist" and used the wonderful &lt;code&gt;dig&lt;/code&gt; command from the terminal with a Bash "for loop" : 

&lt;code&gt;
for i in $(grep . siteslist); do dig $i &#62;&#62; my_looked_up_sites.txt; done
&lt;/code&gt;

This produces a nice document of information about each site (notably the ip address) and now I can clean my server with a bit more confidence. 

this technique is really useful in a wide variety of situations where you have to repeatedly do X for every occurrence of Y. 

For example if you needed to copy a robots.txt file into every subdirectory of a parent "/web" directory you could do something like: 

&lt;code&gt;
for i in $(ls -l &#124;grep '^d' &#124; awk '{print $9}'); do cp /web/robots.txt $i; done
&lt;/code&gt;

&lt;b&gt;Which in english is: &lt;/b&gt;
&lt;code&gt;
ls -l 
&lt;/code&gt;
give a long direcotry listing

&lt;code&gt;
grep '^d'
&lt;/code&gt;
display only the lines for directories

&lt;code&gt;
awk '{print $9}'
&lt;/code&gt;
display only the actual directory name (the 9th column)

&lt;code&gt;
cp /web/robots.txt
&lt;/code&gt;
copy this file into that directory. 

It seems complicated at first but if you are a web developer dealing with lots of sites then it pays to invest in this kind of administrative swiss army knife.</description>
		<content:encoded><![CDATA[<p>Another good one from today: I am transitioning to the new mediatemple grid server (highly recommended), and I have an old apache httpd.conf file with LOTS of old dead Virtual host directives sites on my current server. So there is no need to move them.</p>
<p>Could have used something like <a href="http://www.dnsstuff.com/" rel="nofollow">http://www.dnsstuff.com/</a> (also recommended) to manually look up each url, but instead i just created a list of the addresses called &#8220;siteslist&#8221; and used the wonderful <code>dig</code> command from the terminal with a Bash &#8220;for loop&#8221; : </p>
<p><code><br />
for i in $(grep . siteslist); do dig $i &gt;&gt; my_looked_up_sites.txt; done<br />
</code></p>
<p>This produces a nice document of information about each site (notably the ip address) and now I can clean my server with a bit more confidence. </p>
<p>this technique is really useful in a wide variety of situations where you have to repeatedly do X for every occurrence of Y. </p>
<p>For example if you needed to copy a robots.txt file into every subdirectory of a parent &#8220;/web&#8221; directory you could do something like: </p>
<p><code><br />
for i in $(ls -l |grep '^d' | awk '{print $9}'); do cp /web/robots.txt $i; done<br />
</code></p>
<p><b>Which in english is: </b><br />
<code><br />
ls -l<br />
</code><br />
give a long direcotry listing</p>
<p><code><br />
grep '^d'<br />
</code><br />
display only the lines for directories</p>
<p><code><br />
awk '{print $9}'<br />
</code><br />
display only the actual directory name (the 9th column)</p>
<p><code><br />
cp /web/robots.txt<br />
</code><br />
copy this file into that directory. </p>
<p>It seems complicated at first but if you are a web developer dealing with lots of sites then it pays to invest in this kind of administrative swiss army knife.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Barone</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12575</link>
		<dc:creator>Mike Barone</dc:creator>
		<pubDate>Sat, 21 Oct 2006 03:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12575</guid>
		<description>I don't know how I ever got by without &lt;em&gt;xargs&lt;/em&gt;.

As chrisb mentioned, &lt;code&gt;find&lt;/code&gt; is extremely useful.

&lt;code&gt;awk&lt;/code&gt; and &lt;code&gt;cut&lt;/code&gt; are also very handy.

&lt;code&gt;man&lt;/code&gt; for obvious reasons (&lt;code&gt;man man&lt;/code&gt; if it's not obvious) and because some options for commands like &lt;code&gt;xargs&lt;/code&gt; vary from machine to machine.

Some people that don't use shells very often miss out on some of the &lt;code&gt;builtins&lt;/code&gt; like &lt;code&gt;history&lt;/code&gt; -- every command line you run gets numbered: you can rerun previous command lines by using !num. Example:

&lt;code&gt;
% history
1889  find . -name "*.php" &#124; xargs -I% php -l %
1890  grep -rnI needle * &#124; cut -f1 -d: &#124; sort -u &#124; xargs nedit &#38;
1891  history
% !1889
find . -name "*.php" &#124; xargs -I% php -l %
&#8230;
&lt;/code&gt;

Of course you can press the up-arrow in most shells and go through your command history as well and be sure to take advantage of tab-completion for filenames and commands when possible.

Some additional options for the commands discussed in the article:

&lt;code&gt;grep -v&lt;/code&gt; #will return lines that DON'T match the search string

&lt;code&gt;rsync -u&lt;/code&gt; #update only, don't overwrite newer files
&lt;code&gt;rsync -n&lt;/code&gt; #dry run only, don't actually do anything but list what files would be transferred - useful because rsync is so powerful and flexible and can let you learn and try additional options (--exclude, --delete, etc) before actually executing them.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t know how I ever got by without <em>xargs</em>.</p>
<p>As chrisb mentioned, <code>find</code> is extremely useful.</p>
<p><code>awk</code> and <code>cut</code> are also very handy.</p>
<p><code>man</code> for obvious reasons (<code>man man</code> if it&#8217;s not obvious) and because some options for commands like <code>xargs</code> vary from machine to machine.</p>
<p>Some people that don&#8217;t use shells very often miss out on some of the <code>builtins</code> like <code>history</code> &#8212; every command line you run gets numbered: you can rerun previous command lines by using !num. Example:</p>
<p><code><br />
% history<br />
1889  find . -name "*.php" | xargs -I% php -l %<br />
1890  grep -rnI needle * | cut -f1 -d: | sort -u | xargs nedit &amp;<br />
1891  history<br />
% !1889<br />
find . -name "*.php" | xargs -I% php -l %<br />
&hellip;<br />
</code></p>
<p>Of course you can press the up-arrow in most shells and go through your command history as well and be sure to take advantage of tab-completion for filenames and commands when possible.</p>
<p>Some additional options for the commands discussed in the article:</p>
<p><code>grep -v</code> #will return lines that DON&#8217;T match the search string</p>
<p><code>rsync -u</code> #update only, don&#8217;t overwrite newer files<br />
<code>rsync -n</code> #dry run only, don&#8217;t actually do anything but list what files would be transferred - useful because rsync is so powerful and flexible and can let you learn and try additional options (&#8211;exclude, &#8211;delete, etc) before actually executing them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12368</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Wed, 18 Oct 2006 23:38:59 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12368</guid>
		<description>@chrisb: Thanks for your comments and input. &lt;acronym title="As Far As I Know"&gt;AFAIK&lt;/acronym&gt; sed can be used to rename files but only indirectly, by changing text which can then be used via redirection as a filename.</description>
		<content:encoded><![CDATA[<p>@chrisb: Thanks for your comments and input. <acronym title="As Far As I Know">AFAIK</acronym> sed can be used to rename files but only indirectly, by changing text which can then be used via redirection as a filename.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chrisb</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12340</link>
		<dc:creator>chrisb</dc:creator>
		<pubDate>Wed, 18 Oct 2006 20:14:17 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12340</guid>
		<description>also from the I-really-used-it-this-week department:

&lt;code&gt;
find / -type f -size +500000k
&lt;/code&gt;

will give you all the files on your system that are larger than 500 MB. Simple but undeniably useful when running &lt;code&gt;df&lt;/code&gt; shows 95% full. 

This list is great because most shell tutorials focus on the *real* geeky sysadmin stuff. Which is useless for the photoshop jockeys. 

Personally it has only been in the last year that I realized how much it pays to learn basic command line. I would love to see other commenters post their web-developer-relevant commands.</description>
		<content:encoded><![CDATA[<p>also from the I-really-used-it-this-week department:</p>
<p><code><br />
find / -type f -size +500000k<br />
</code></p>
<p>will give you all the files on your system that are larger than 500 MB. Simple but undeniably useful when running <code>df</code> shows 95% full. </p>
<p>This list is great because most shell tutorials focus on the *real* geeky sysadmin stuff. Which is useless for the photoshop jockeys. </p>
<p>Personally it has only been in the last year that I realized how much it pays to learn basic command line. I would love to see other commenters post their web-developer-relevant commands.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: chrisb</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12339</link>
		<dc:creator>chrisb</dc:creator>
		<pubDate>Wed, 18 Oct 2006 20:01:54 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12339</guid>
		<description>"rename" is also a nice unix command that is a little less intimidating for those who haven't got so much experience with regular expressions. 

rename .html .php *.html

substitutes .html with .php in files ending in .html. 

easy-peasy. 

anyway, does sed work on filenames?</description>
		<content:encoded><![CDATA[<p>&#8220;rename&#8221; is also a nice unix command that is a little less intimidating for those who haven&#8217;t got so much experience with regular expressions. </p>
<p>rename .html .php *.html</p>
<p>substitutes .html with .php in files ending in .html. </p>
<p>easy-peasy. </p>
<p>anyway, does sed work on filenames?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ismael</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12129</link>
		<dc:creator>Ismael</dc:creator>
		<pubDate>Mon, 16 Oct 2006 14:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12129</guid>
		<description>Very useful indeed. Thankyou!</description>
		<content:encoded><![CDATA[<p>Very useful indeed. Thankyou!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/10/16/six-useful-shell-commands-for-web-developers/#comment-12123</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Mon, 16 Oct 2006 11:57:04 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/10/16/six-shell-commands-every-web-developer-should-know/#comment-12123</guid>
		<description>@Phu: thanks!

@Dave: That's a good addition thanks.</description>
		<content:encoded><![CDATA[<p>@Phu: thanks!</p>
<p>@Dave: That&#8217;s a good addition thanks.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
