<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tail -f /dev/null &#187; replace</title>
	<atom:link href="http://tfdn.radiofreeomaha.net/tag/replace/feed/" rel="self" type="application/rss+xml" />
	<link>http://tfdn.radiofreeomaha.net</link>
	<description>Tips, notes, HOWTOs</description>
	<lastBuildDate>Fri, 20 Aug 2010 04:13:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Simple Vim Macros</title>
		<link>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/</link>
		<comments>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 18:27:29 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Config]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[variable]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=96</guid>
		<description><![CDATA[I found myself editing a configuration file (multiple actually) at work today and ran into an issue.  The config file looked similar to: Var_1=A Var_2=B Var_3=C ... Var_146=ABC Var_147=ABD As it happened I needed to remove one of the lines at position 23.  The program that reads/uses these config files has an issue if there [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I found myself editing a configuration file (multiple actually) at work today and ran into an issue.  The config file looked similar to:</p>
<pre class="brush: bash">
Var_1=A
Var_2=B
Var_3=C
...
Var_146=ABC
Var_147=ABD
</pre>
<p>As it happened I needed to remove one of the lines at position 23.  The program that reads/uses these config files has an issue if there is a break in the sequence.  So after removing the line with &#8220;Var_23&#8243; I needed to shift all of the numbers in following lines down by 1.  Here is how I accomplished that.</p>
<p>In vim I put my cursor on the 24 in the line that now follows the &#8220;Var_22&#8243; line and performed the following commands:</p>
<pre class="brush: bash">
qa
CTRL-X
j
q
125@a
</pre>
<p>Here is what happened broken down by line:</p>
<p>1: Here I am recording a macro (q) with the name or identifier of &#8216;a&#8217;.  Note you will probably see some indication in the last line that you are in &#8220;recording&#8221; mode.</p>
<p>2: CTRL-X decrements the number under the cursor.  Since I am on the 24 that decrements it to 23.</p>
<p>3:  I move down 1 line and now the cursor is on the 25 in the next line.</p>
<p>4: I quit recording the macro.  I know have a named (a) macro that includes the commands &#8220;decrement the number under the cursor and move down one row&#8221;.</p>
<p>5: I perform that named (a) macro 125 times.  Now realistically I only needed to do it 123 times.  It didn&#8217;t seem to matter that I used 125 but YMMV.  The first line after the last line I wanted to change was a blank line so I assume the macro quit when the CTRL-X failed.  You are probably better off using the exact number.</p>
<p>And there you have it.  I successfully renumbered all of the variables below the line I deleted to be in sequence.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/pixy.gif?x-id=9ec0d12e-548c-44ca-8cc8-0f9543ba456a" alt="" /><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2009/11/simple-vim-macros/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add A Comma To The End Of A Line</title>
		<link>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/</link>
		<comments>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 16:59:49 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[vi]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[substitute]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=66</guid>
		<description><![CDATA[I work with long lists and WinSQL a lot.  I always find myself wishing these long lists had commas at the end for pasting into a SQL where clause using &#8220;IN&#8221; for the list.  This can be accomplished in one of two ways. From the command line: sed &#34;s/$/,/g&#34; &#60;FILENAME&#62; I usually pipe the output [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I work with long lists and WinSQL a lot.  I always find myself wishing these long lists had commas at the end for pasting into a SQL where clause using &#8220;IN&#8221; for the list.  This can be accomplished in one of two ways.</p>
<p>From the command line:</p>
<pre class="brush: bash">sed &quot;s/$/,/g&quot; &lt;FILENAME&gt;</pre>
<p>I usually pipe the output there to a new file.</p>
<p>In vi (from command mode):</p>
<pre class="brush: bash">:%s/$/,/g</pre>
<p>The &#8220;%&#8221; says to perfom the substitution on the whole file.  In both cases we are doing a substitution of &#8220;$&#8221; (the end of the line) with a &#8220;,&#8221;.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2009/01/add-a-comma-to-the-end-of-a-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Global Search And Replace In Vi</title>
		<link>http://tfdn.radiofreeomaha.net/2008/12/global-search-and-replace-in-vi/</link>
		<comments>http://tfdn.radiofreeomaha.net/2008/12/global-search-and-replace-in-vi/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 18:30:40 +0000</pubDate>
		<dc:creator>Uncle Jubba</dc:creator>
				<category><![CDATA[vi]]></category>
		<category><![CDATA[replace]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://tfdn.radiofreeomaha.net/?p=27</guid>
		<description><![CDATA[To perform a global search and replace in vi do: :%s/search_string/replacement_string/g If you want to confirm each replacement add a &#8220;c&#8221; after the &#8220;g&#8221; at the end of the string. No related posts.
No related posts.]]></description>
			<content:encoded><![CDATA[<p>To perform a global search and replace in vi do:</p>
<pre>
<pre class="brush: bash">:%s/search_string/replacement_string/g</pre>
<p>If you want to confirm each replacement add a &#8220;c&#8221; after the &#8220;g&#8221; at the end of the string.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://tfdn.radiofreeomaha.net/2008/12/global-search-and-replace-in-vi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

