<?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>Bridge to Nova &#187; Linux</title>
	<atom:link href="http://www.bridgetonova.com/category/linux/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bridgetonova.com</link>
	<description>Tech News, Tips and Tricks, Howto, Workarounds, SEO, Alexa tips.</description>
	<lastBuildDate>Fri, 23 Dec 2011 07:40:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Simple ls command to list only files</title>
		<link>http://www.bridgetonova.com/2011/11/simple-ls-command-to-list-only-files.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-ls-command-to-list-only-files</link>
		<comments>http://www.bridgetonova.com/2011/11/simple-ls-command-to-list-only-files.html#comments</comments>
		<pubDate>Wed, 16 Nov 2011 03:33:38 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[hide directory from ls commands]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[ls command]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/?p=1320</guid>
		<description><![CDATA[I&#8217;ve been looking for ls option to hide directory. After a few googling, most people suggested quite complicated commands. Finally, I&#8217;ve found the really very simple command for this simple [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for ls option to hide directory. After a few googling, most people suggested quite complicated commands. Finally, I&#8217;ve found the really very simple command for this simple task from Devshed forums.</p>
<p>Here it is. You just need to ignore &#8220;/&#8221; from ls output.</p>
<pre class="brush: plain; title: ; notranslate">ls | grep -v &quot;/&quot;</pre>
<p>Source : <a href="http://forums.devshed.com/unix-help-35/ls-files-not-directorys-222535.html">Devshed forums</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/11/simple-ls-command-to-list-only-files.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to install sshd and config for authentication with private key only</title>
		<link>http://www.bridgetonova.com/2011/10/how-to-install-sshd-and-config-for-authentication-with-private-key-only.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-install-sshd-and-config-for-authentication-with-private-key-only</link>
		<comments>http://www.bridgetonova.com/2011/10/how-to-install-sshd-and-config-for-authentication-with-private-key-only.html#comments</comments>
		<pubDate>Sun, 30 Oct 2011 00:34:43 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[private key]]></category>
		<category><![CDATA[public key]]></category>
		<category><![CDATA[ssh keys]]></category>
		<category><![CDATA[sshd]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/?p=1242</guid>
		<description><![CDATA[Once the system is up and running, the first thing for most linux system admin to do is to install sshd and configure authentication. Nowadays, most IT companies will not [...]]]></description>
			<content:encoded><![CDATA[<p>Once the system is up and running, the first thing for most linux system admin to do is to install sshd and configure authentication. Nowadays, most IT companies will not allow password based authentication anymore. Most coporate environment favours ssh key based authentication. Of course, there are hundreds of different methods to do this. Here is one of my favourite and simplest guide.</p>
<p>I&#8217;ve assumed you use Debian based linux and logon under root. If you are using other linux, change the command to yum or whatever package management system you used.</p>
<blockquote>
<ul>
<li>First install ssh server.</li>
<p>         ~$apt-get install openssh-server
</ul>
<ul>
<li>Edit sshdconfig file</li>
<p>~$vi /etc/ssh/sshd_config
</ul>
<ul>
<li>Disable password authentication by putting the following line</li>
<p>PasswordAuthentication no
</ul>
<ul>
<li>For keys file location, I prefer to put in file by user name</li>
<p>AuthorizedKeysFile /etc/ssh/keys/%u
</ul>
<ul>
<li>Save the file</ul>
</li>
<ul>
<li>Copy the public key of the users and put in /etc/ssh/keys/</li>
</ul>
<ul>
<li>Restart the ssh demon by entering the following command</li>
<p>/etc/init.d/ssh restart</ul>
</blockquote>
<p>That&#8217;s it! Your users need to use their private key to login to the server from now on.</p>
<p>Source : <a href="http://www.openbsd.org/cgi-bin/man.cgi?query=sshd&amp;sektion=8">OpenBSD</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/10/how-to-install-sshd-and-config-for-authentication-with-private-key-only.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add users into sudoers</title>
		<link>http://www.bridgetonova.com/2011/10/how-to-add-users-into-sudoers.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-add-users-into-sudoers</link>
		<comments>http://www.bridgetonova.com/2011/10/how-to-add-users-into-sudoers.html#comments</comments>
		<pubDate>Sat, 29 Oct 2011 00:07:40 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debain]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[sudoers]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/?p=1240</guid>
		<description><![CDATA[First of all, you need to have sudo package installed. You can check if your system have by typing visudo command. root@SUNNYVALE-133:~# visudo -su: /usr/sbin/visudo: No such file or directory [...]]]></description>
			<content:encoded><![CDATA[<p>First of all, you need to have sudo package installed. You can check if your system have by typing visudo command.</p>
<blockquote><p>root@SUNNYVALE-133:~# visudo<br />
-su: /usr/sbin/visudo: No such file or directory</p></blockquote>
<p>If you receive the above error, that means you don&#8217;t have sudo module. You can install by typing the following command:</p>
<blockquote><p>root@SUNNYVALE-133:~# apt-get install sudo</p></blockquote>
<p>Once you&#8217;ve got sudo package installed, you can add users to sudoers file. The following is my sample config.</p>
<ul>
<li>First type visudo command</li>
<li>The add the following line under root ALL=(ALL) ALL line<br />
mysampleuser ALL = (ALL) ALL, NOPASSWD: ALL</li>
</ul>
<p>That&#8217;s it! From now on, you can simple type sudo su &#8211; whenever you want to become root from your own username.</p>
<p>Source : <a href="http://wiki.debian.org/sudo">Debian Wiki</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/10/how-to-add-users-into-sudoers.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to resolve &#8220;Can&#8217;t locate DBD/Pg.pm&#8221; error</title>
		<link>http://www.bridgetonova.com/2011/10/how-to-resolve-cant-locate-dbdpg-pm-error.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-resolve-cant-locate-dbdpg-pm-error</link>
		<comments>http://www.bridgetonova.com/2011/10/how-to-resolve-cant-locate-dbdpg-pm-error.html#comments</comments>
		<pubDate>Fri, 28 Oct 2011 02:53:12 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[can't locate DBD]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/?p=1238</guid>
		<description><![CDATA[I was having the following perl module missing error. root@SUNNYVALE-133:/# ./myscript.pl Can&#8217;t locate DBD/Pg.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ./myscript.pl line [...]]]></description>
			<content:encoded><![CDATA[<p>I was having the following perl module missing error. </p>
<blockquote><p>root@SUNNYVALE-133:/# ./myscript.pl<br />
Can&#8217;t locate DBD/Pg.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ./myscript.pl line 5.<br />
BEGIN failed&#8211;compilation aborted at ./myscript.pl line 5.</p></blockquote>
<p>After googling for a while, most websites directed me to do the following. </p>
<blockquote><p>
$cpan<br />
cpan&gt;install DBI<br />
cpan&gt;install DBD::Pg</p></blockquote>
<p>Even after I&#8217;ve done that, I&#8217;m still having the same error message. Eventually I&#8217;ve found out that since I&#8217;m using Debian, I should rather just install the perl pg library. The following command is the one that solve my problem.</p>
<blockquote><p>root@SUNNYVALE-133:/#apt-get install libdbd-pg-perl</p></blockquote>
<p>I hope this would be helpful to you as well if you&#8217;re getting the same error message.</p>
<p>Source : <a href="http://dbi.perl.org/support/">Perl DBI Support</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/10/how-to-resolve-cant-locate-dbdpg-pm-error.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to renew dhcp lease in Linux</title>
		<link>http://www.bridgetonova.com/2011/09/how-to-renew-dhcp-lease-in-linux.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-renew-dhcp-lease-in-linux</link>
		<comments>http://www.bridgetonova.com/2011/09/how-to-renew-dhcp-lease-in-linux.html#comments</comments>
		<pubDate>Fri, 16 Sep 2011 21:40:00 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[dhcp]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/09/how-to-renew-dhcp-lease-in-linux.html</guid>
		<description><![CDATA[I’ve tried this command on Debian/Ubuntu, but since dhcpclient is the universal across all distros, I expect this to work on all *.nix variants. First thing to take note is [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve tried this command on Debian/Ubuntu, but since dhcpclient is the universal across all distros, I expect this to work on all *.nix variants.</p>
<p>First thing to take note is if you are ssh to the server, you should be careful before executing the commands.</p>
<blockquote><p><span style="color: #800000"><strong>sudo dhclient –r</strong></span></p></blockquote>
<p>The above command will cause all network adapters to release DHCP lease. So if you are ssh through one of the DHCP interface, you’ll get disconnected and unless you’ve physical or console access, there is no way to bring it back.</p>
<p>So I’ve come up with nice commands that you can use even if you don’t have console or physical access to the server. But you should be able to ssh to the host by using hostname in case DHCP server lease a new different IP addresses. If DHCP server responded with the same IP address, you won’t even get disconnect from ssh session.</p>
<blockquote><p><span style="color: #800000"><strong>sudo dhclient -r; sudo killall -9 dhclient</strong></span></p></blockquote>
<p>That’s the command I’ve used frequently and very convenient for me.</p>
<p>Source : <a href="http://manpages.ubuntu.com/manpages/maverick/man8/dhclient3.8.html">Ubuntu Manpages</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/09/how-to-renew-dhcp-lease-in-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Change hostname in Ubuntu or Debian</title>
		<link>http://www.bridgetonova.com/2011/09/change-hostname-in-ubuntu-or-debian.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=change-hostname-in-ubuntu-or-debian</link>
		<comments>http://www.bridgetonova.com/2011/09/change-hostname-in-ubuntu-or-debian.html#comments</comments>
		<pubDate>Thu, 15 Sep 2011 21:55:00 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[hostname]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/09/change-hostname-in-ubuntu-or-debian.html</guid>
		<description><![CDATA[If you’ve changed your mind about your Linux hostname or you’ve set to wrong hostname, here is how to fix it. Firstly, I’ve tried the following command: $sudo hostname mybrandnewname [...]]]></description>
			<content:encoded><![CDATA[<p>If you’ve changed your mind about your Linux hostname or you’ve set to wrong hostname, here is how to fix it.</p>
<p>Firstly, I’ve tried the following command:</p>
<blockquote><p><strong><span style="color: #800000">$sudo hostname mybrandnewname</span></strong></p></blockquote>
<p>But this will revert back to prior hostname whenever the machine reboots. So how can you change it permanently? First you&#8217;ll need to edit /etc/hostname file</p>
<blockquote><p><strong><span style="color: #800000">$sudo vi /etc/hostname Then delete the old name and type whatevername you desire </span></strong></p></blockquote>
<p>It is also advisable to change new hostname in /etc/hosts file</p>
<p>Source : <a href="http://ubuntumanual.org/posts/143/how-to-change-computer-name-in-ubuntu">UbuntuManual</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/09/change-hostname-in-ubuntu-or-debian.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to add new user and grant permission?</title>
		<link>http://www.bridgetonova.com/2011/09/how-to-add-new-user-and-grant-permission.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-add-new-user-and-grant-permission</link>
		<comments>http://www.bridgetonova.com/2011/09/how-to-add-new-user-and-grant-permission.html#comments</comments>
		<pubDate>Wed, 14 Sep 2011 21:05:00 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[linux commands]]></category>
		<category><![CDATA[new user]]></category>
		<category><![CDATA[sudoers]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/09/how-to-add-new-user-and-grant-permission.html</guid>
		<description><![CDATA[Once you’ve got your new favourite Linux distro installed, you’ll need to add users and grant permission as per your organization requirement. The steps are very simple and straightforward. sudo [...]]]></description>
			<content:encoded><![CDATA[<p>Once you’ve got your new favourite Linux distro installed, you’ll need to add users and grant permission as per your organization requirement.</p>
<p>The steps are very simple and straightforward.</p>
<p>sudo adduser <username> <usergroup></p>
<p>If you want to grant a user to all permissions as root, you should add that user to admin group. For example :</p>
<p>sudo adduser jason admin</p>
<p>Make sure the line “<code>%admin ALL=(ALL) ALL</code>&#8221; is present in the /etc/sudoers. The below is the screenshot of sample config file.</p>
<p><a href="http://www.bridgetonova.com/wp-content/uploads/2011/09/sudoers_screenshot.png"><img style="border: 0px" src="http://www.bridgetonova.com/wp-content/uploads/2011/09/sudoers_screenshot_thumb.png" alt="sudoers_screenshot" width="440" height="78" border="0" /></a></p>
<p>After that you might want to set specific password for the new user. You can do this by using the following command:</p>
<p>sudo passwd <username></p>
<p>Source : <a href="http://askubuntu.com/questions/7477/how-can-i-add-a-new-user-as-sudoer">AskUbuntu</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/09/how-to-add-new-user-and-grant-permission.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to config ubuntu/debian to boot in text mode</title>
		<link>http://www.bridgetonova.com/2011/09/how-to-config-ubuntudebian-to-boot-in-text-mode.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-config-ubuntudebian-to-boot-in-text-mode</link>
		<comments>http://www.bridgetonova.com/2011/09/how-to-config-ubuntudebian-to-boot-in-text-mode.html#comments</comments>
		<pubDate>Wed, 14 Sep 2011 01:00:00 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[boot text mode]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tricks]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/09/how-to-config-ubuntudebian-to-boot-in-text-mode.html</guid>
		<description><![CDATA[I like Linux boxes to boot directly to terminal mode. If you’ve just moved to Ubuntu distro from Red Hat/ Fedora, you’ll think about changing the inittab. Well, bad news [...]]]></description>
			<content:encoded><![CDATA[<p>I like Linux boxes to boot directly to terminal mode. If you’ve just moved to Ubuntu distro from Red Hat/ Fedora, you’ll think about changing the inittab. Well, bad news is in Debain or any of its derivatives, runlevels 2 to 5 are the same multi-user with display GUI. So if you type, sudo init 3, nothing will happen.</p>
<p>So here is how I make Ubuntu to boot into text mode by default. The requirement for this is you have to use grub as boot loader.</p>
<p>Just edit the /etc/default/grub using any of your favourite text editor, look for the line</p>
<p><strong><span style="color: #800000">GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet splash&#8221;</span></strong></p>
<p>Then changed it to</p>
<p><strong><span style="color: #800000">GRUB_CMDLINE_LINUX_DEFAULT=&#8221;text&#8221;</span></strong></p>
<p>The following is the screenshot for what my grub file looks like after the changes.</p>
<p><a href="http://www.bridgetonova.com/wp-content/uploads/2011/09/grub_ubuntu_screenshot1.png"><img style="border: 0px" src="http://www.bridgetonova.com/wp-content/uploads/2011/09/grub_ubuntu_screenshot_thumb1.png" alt="grub_ubuntu_screenshot" width="504" height="175" border="0" /></a></p>
<p>After that save the file and run <strong><span style="color: #800000">sudo update-grub</span></strong>. That’s it. Starting from next reboot, your ubuntu/debian variants will start in text mode.</p>
<p>Source : <a href="http://ubuntuforums.org/showthread.php?t=1483038">UbuntuForums</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/09/how-to-config-ubuntudebian-to-boot-in-text-mode.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to reverse a string using sed</title>
		<link>http://www.bridgetonova.com/2011/09/how-to-reverse-a-string-using-sed.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-reverse-a-string-using-sed</link>
		<comments>http://www.bridgetonova.com/2011/09/how-to-reverse-a-string-using-sed.html#comments</comments>
		<pubDate>Tue, 13 Sep 2011 02:09:14 +0000</pubDate>
		<dc:creator>jason</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Tricks]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/09/how-to-reverse-a-string-using-sed.html</guid>
		<description><![CDATA[I had got issue with having to reverse a string of number manually. Of course, that gave me a big headache. Thanks to Peter from Catonmat, I’ve got the following [...]]]></description>
			<content:encoded><![CDATA[<p>I had got issue with having to reverse a string of number manually. Of course, that gave me a big headache. Thanks to Peter from <a href="http://www.catonmat.net/blog/sed-one-liners-explained-part-one/">Catonmat</a>, I’ve got the following sed script.</p>
<blockquote><p><span style="color: #800000"><strong>sed &#8216;/\n/!G;s/\(.\)\(.*\n\)/&amp;\2\1/;//D;s/.//&#8217;</strong></span></p>
</blockquote>
<p>As you can imagine, this is quite complicated, but luckily he’s given nice explanation as well.</p>
<blockquote><pre></pre>
<p><span style="color: #800000"><strong>sed &#8216; </strong></span></p>
<p><span style="color: #800000"><strong>/\n/ !G </strong></span></p>
<p><span style="color: #800000"><strong>s/\(.\)\(.*\n\)/&amp;\2\1/ </strong></span></p>
<p><span style="color: #800000"><strong>//D </strong></span></p>
<p><span style="color: #800000"><strong>s/.// &#8216; </strong></span></p>
<p><span style="color: #800000"></span>The first line &#8220;/\n/ !G&#8221; appends a newline to the end of the pattern space if there was none.</p>
<p>The second line &#8220;s/\(.\)\(.*\n\)/&amp;\2\1/&#8221; is a simple s/// expression which groups the first character as \1 and all the others as \2. Then it replaces the whole matched string with &#8220;&amp;\2\1&#8243;, where &#8220;&amp;&#8221; is the whole matched text (&#8220;\1\2&#8243;). For example, if the input string is &#8220;1234&#8243; then after the s/// expression, it becomes &#8220;1234\n234\n1&#8243;.</p>
<p>The third line is &#8220;//D&#8221;. This statement is the key in this one-liner. An empty pattern // matches the last existing regex, so it&#8217;s exactly the same as: /\(.\)\(.*\n\)/D. The &#8220;D&#8221; command deletes from the start of the input till the first newline and then resumes editing with first command in script. It creates a loop. As long as /\(.\)\(.*\n\)/ is satisfied, sed will resume all previous operations. After several loops, the text in the pattern space becomes &#8220;\n4321&#8243;. Then /\(.\)\(.*\n\)/ fails and sed goes to the next command.</p>
<p>The fourth line &#8220;s/.//&#8221; removes the first character in the pattern space which is the newline char. The contents in pattern space becomes &#8220;4321&#8243; &#8212; reverse of &#8220;1234&#8243;.</p>
</blockquote>
<p>But what I want is the output to be separated by “.” aka dot character. So here’s what I come up with.</p>
<blockquote>
<p><strong><span style="color: #800000">$ echo 123456789 | sed &#8216;/\n/!G;s/\(.\)\(.*\n\)/&amp;\2.\1/;//D;s/.//&#8217;</p>
<p>.9.8.7.6.5.4.3.2.1</span></strong></p>
</blockquote>
<p>Still there’s one small issue, I don’t want dot at the start of the string. So after reading his explanation, I realize that I need to put one more “.” to be replaced at the fourth line. This is final script.</p>
<blockquote>
<p><strong><span style="color: #800000">$ echo 123456789 | sed &#8216;/\n/!G;s/\(.\)\(.*\n\)/&amp;\2.\1/;//D;s/..//&#8217;</p>
<p>9.8.7.6.5.4.3.2.1</span></strong></p>
</blockquote>
<p>So obviously, if you want “,” aka comma instead of dot, you can just substitute it. If you are curious about getting to know sed, why don’t you head over to catonmat.net. That site got so many cool sed one liners.</p>
<p>Source : <a href="http://www.catonmat.net/blog/sed-one-liners-explained-part-one/">Catonmat</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/09/how-to-reverse-a-string-using-sed.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to rename multiple files in Linux</title>
		<link>http://www.bridgetonova.com/2011/08/how-to-rename-multiple-files-in-linux.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-rename-multiple-files-in-linux</link>
		<comments>http://www.bridgetonova.com/2011/08/how-to-rename-multiple-files-in-linux.html#comments</comments>
		<pubDate>Sat, 27 Aug 2011 01:46:00 +0000</pubDate>
		<dc:creator>Jason</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.bridgetonova.com/2011/08/how-to-rename-multiple-files-in-linux.html</guid>
		<description><![CDATA[From time to time, we may need to rename multiple files in Linux. It is quite frustrating to find out that mv old_name* new_name* is not working actually. So after [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time, we may need to rename multiple files in Linux. It is quite frustrating to find out that mv old_name* new_name* is not working actually. </p>
<p>So after a few trials and errors, I’ve got the following script, which is really time saver for me. </p>
<p>This is what my files look like before the script.</p>
<blockquote><p>$ ls -lth     <br />total 12K      <br />-rw-r&#8211;r&#8211; 1 username group 6 Aug 26 01:38 old_name_3.txt      <br />-rw-r&#8211;r&#8211; 1 username group 6 Aug 26 01:38 old_name_2.txt      <br />-rw-r&#8211;r&#8211; 1 username group 5 Aug 26 01:38 old_name_1.txt</p>
</blockquote>
<p>I want to rename all those old_name to new_name. Here is the script to do that: </p>
<blockquote><p>$ for nn in `ls -1 old*`; do NAME=`echo $nn | sed -e &#8216;s/^old_name/new_name/g&#8217;`; mv $nn $NAME; done</p>
</blockquote>
<p>This is the aftermath. </p>
<blockquote><p>$ ls -lth     <br />total 12K      <br />-rw-r&#8211;r&#8211; 1 username group 6 Aug 26 01:38 new_name_3.txt      <br />-rw-r&#8211;r&#8211; 1 username group 6 Aug 26 01:38 new_name_2.txt      <br />-rw-r&#8211;r&#8211; 1 username group 5 Aug 26 01:38 new_name_1.txt</p>
</blockquote>
<p>I hope this script will be helpful for you as well. As always, feel free to leave a comment if you need any help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bridgetonova.com/2011/08/how-to-rename-multiple-files-in-linux.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

