<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Useful bash tricks: learning from history</title>
	<atom:link href="http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/feed/" rel="self" type="application/rss+xml" />
	<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/</link>
	<description>experiences with computers.  updated infrequently.</description>
	<lastBuildDate>Tue, 07 Jul 2009 13:29:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Rajeev</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-104</link>
		<dc:creator>Rajeev</dc:creator>
		<pubDate>Tue, 06 May 2008 14:08:07 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-104</guid>
		<description>&lt;p&gt;hi,&lt;/p&gt;

&lt;p&gt;i would like to have a way to execute last N commands from history. For example - 
cd dir1
rm file1
cd ../dir2
rm file 2
cd ..&lt;/p&gt;

&lt;p&gt;say above are the 5 commands. I would like to execute these 5 commands. How to do it ?&lt;/p&gt;

&lt;p&gt;I wrote this shell script - repeat.sh.&lt;/p&gt;

&lt;p&gt;!/bin/sh&lt;/p&gt;

&lt;p&gt;echo &quot;start&quot;
for i in &lt;code&gt;history &#124; tail -4 &#124; tr -s &quot; &quot;&#124; cut -d &quot; &quot;  -f3-&lt;/code&gt;
do
    echo $i
done
echo &quot;end&quot;&lt;/p&gt;

&lt;p&gt;Facing a small issue with this. The &quot;i&quot; variable is assigned values like - &quot;cd&quot; &quot;dir1&quot; &quot;rm&quot; &quot;file1&quot; ... i.e the command is sometimes split across spaces and assigned. Instead would like to have the entire line as one command.&lt;/p&gt;

&lt;p&gt;Any pointers to achieve this ?
OR any builtin in bash to execute last n commands in history.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>hi,</p>

<p>i would like to have a way to execute last N commands from history. For example &#8211; 
cd dir1
rm file1
cd ../dir2
rm file 2
cd ..</p>

<p>say above are the 5 commands. I would like to execute these 5 commands. How to do it ?</p>

<p>I wrote this shell script &#8211; repeat.sh.</p>

<p>!/bin/sh</p>

<p>echo &#8220;start&#8221;
for i in <code>history | tail -4 | tr -s " "| cut -d " "  -f3-</code>
do
    echo $i
done
echo &#8220;end&#8221;</p>

<p>Facing a small issue with this. The &#8220;i&#8221; variable is assigned values like &#8211; &#8220;cd&#8221; &#8220;dir1&#8243; &#8220;rm&#8221; &#8220;file1&#8243; &#8230; i.e the command is sometimes split across spaces and assigned. Instead would like to have the entire line as one command.</p>

<p>Any pointers to achieve this ?
OR any builtin in bash to execute last n commands in history.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: jon</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-30</link>
		<dc:creator>jon</dc:creator>
		<pubDate>Sat, 15 Mar 2008 12:48:01 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-30</guid>
		<description>&lt;p&gt;@ CR: it means PRESS the alt key toghether with . (point)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>@ CR: it means PRESS the alt key toghether with . (point)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: bob</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-24</link>
		<dc:creator>bob</dc:creator>
		<pubDate>Fri, 14 Mar 2008 00:21:11 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-24</guid>
		<description>&lt;p&gt;More fun commands are:
history (to find the number of a command you want to run:&lt;/p&gt;

&lt;p&gt;!47 (to run the 47th command)
!47:s/search/replace/ (Mix of that and the ^ syntax)
!-2 (run the command two previous to the current position in the history&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>More fun commands are:
history (to find the number of a command you want to run:</p>

<p>!47 (to run the 47th command)
!47:s/search/replace/ (Mix of that and the ^ syntax)
!-2 (run the command two previous to the current position in the history</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Ramsey</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-19</link>
		<dc:creator>Ramsey</dc:creator>
		<pubDate>Mon, 03 Mar 2008 10:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-19</guid>
		<description>&lt;p&gt;You can also use ! to run the last command beginning with those characters. For example, you can run &quot;grep -i &quot;foo&quot; file&quot; then run ten others commands other than grep and then type &quot;!grep&quot; to run the grep command again. This saves me TONS of time.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You can also use ! to run the last command beginning with those characters. For example, you can run &#8220;grep -i &#8220;foo&#8221; file&#8221; then run ten others commands other than grep and then type &#8220;!grep&#8221; to run the grep command again. This saves me TONS of time.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: CR</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-16</link>
		<dc:creator>CR</dc:creator>
		<pubDate>Tue, 26 Feb 2008 20:31:16 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-16</guid>
		<description>&lt;p&gt;$ mkdir foo&lt;br /&gt;
$ cd ALT&lt;br /&gt;
-bash: cd: ALT: No such file or directory&lt;/p&gt;

&lt;p&gt;doh!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>$ mkdir foo<br />
$ cd ALT<br />
-bash: cd: ALT: No such file or directory</p>

<p>doh!</p>]]></content:encoded>
	</item>
	<item>
		<title>By: leoboiko</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-15</link>
		<dc:creator>leoboiko</dc:creator>
		<pubDate>Tue, 26 Feb 2008 19:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-15</guid>
		<description>&lt;p&gt;Newlines added.  Alt+. is nice to know, but I think I’ll keep using !$, because of my keyboard layout.  The shortcut is actually Meta+., and I keep my Meta key as the Windows key; I find it kind of clunky to press with ‘.’.&lt;/p&gt;

&lt;p&gt;Or maybe I’m just rationalizing resistence to change =)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Newlines added.  Alt+. is nice to know, but I think I’ll keep using !$, because of my keyboard layout.  The shortcut is actually Meta+., and I keep my Meta key as the Windows key; I find it kind of clunky to press with ‘.’.</p>

<p>Or maybe I’m just rationalizing resistence to change =)</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Doar</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-14</link>
		<dc:creator>Matt Doar</dc:creator>
		<pubDate>Tue, 26 Feb 2008 19:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-14</guid>
		<description>&lt;p&gt;Ack, insert new line after the mkdir commands&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Ack, insert new line after the mkdir commands</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Doar</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-13</link>
		<dc:creator>Matt Doar</dc:creator>
		<pubDate>Tue, 26 Feb 2008 19:19:20 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-13</guid>
		<description>&lt;p&gt;I believe that ALT . is a shortcut for the last part of the last command too. So instead of &lt;/p&gt;

&lt;p&gt;mkdir foo&lt;br /&gt;
cd foo&lt;/p&gt;

&lt;p&gt;I type &lt;/p&gt;

&lt;p&gt;mkdir foo&lt;br /&gt;
cd ALT .&lt;/p&gt;

&lt;p&gt;and the result is the same&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I believe that ALT . is a shortcut for the last part of the last command too. So instead of </p>

<p>mkdir foo<br />
cd foo</p>

<p>I type </p>

<p>mkdir foo<br />
cd ALT .</p>

<p>and the result is the same</p>]]></content:encoded>
	</item>
	<item>
		<title>By: leoboiko</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-12</link>
		<dc:creator>leoboiko</dc:creator>
		<pubDate>Tue, 26 Feb 2008 18:42:31 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-12</guid>
		<description>&lt;p&gt;that’s interesting, thanks.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>that’s interesting, thanks.</p>]]></content:encoded>
	</item>
	<item>
		<title>By: Peteris Krumins</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-11</link>
		<dc:creator>Peteris Krumins</dc:creator>
		<pubDate>Tue, 26 Feb 2008 18:36:59 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-11</guid>
		<description>&lt;p&gt;Hey! I recently wrote a &#039;&lt;a href=&quot;http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/&quot; rel=&quot;nofollow&quot;&gt;Definitive Guide to Bash History&lt;/a&gt;&#039;, you might be interested:&lt;/p&gt;

&lt;p&gt;http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hey! I recently wrote a &#8216;<a href="http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/" rel="nofollow">Definitive Guide to Bash History</a>&#8216;, you might be interested:</p>

<p><a href="http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/" rel="nofollow">http://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/</a></p>]]></content:encoded>
	</item>
	<item>
		<title>By: tabgal</title>
		<link>http://namakajiri.net/complog/useful-bash-tricks-learning-from-history/comment-page-1/#comment-9</link>
		<dc:creator>tabgal</dc:creator>
		<pubDate>Sun, 24 Feb 2008 13:19:49 +0000</pubDate>
		<guid isPermaLink="false">http://namakajiri.net/complog/useful-bash-variables-learning-from-the-history/#comment-9</guid>
		<description>&lt;p&gt;&quot;^&lt;foo&gt;^&lt;bar&gt; Repeats the last command, substituting “bar” for the first “foo” (like s/foo/bar/ in vi).&quot;&lt;/p&gt;

&lt;p&gt;OHMAGA!!!1111 Era isso que eu queria!&lt;/p&gt;

&lt;p&gt;aptitude search liblolcats&lt;br /&gt;
aptitude install liblolcats&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>&#8220;^&lt;foo&gt;^&lt;bar&gt; Repeats the last command, substituting “bar” for the first “foo” (like s/foo/bar/ in vi).&#8221;</p>

<p>OHMAGA!!!1111 Era isso que eu queria!</p>

<p>aptitude search liblolcats<br />
aptitude install liblolcats</p>]]></content:encoded>
	</item>
</channel>
</rss>
