Thursday, November 22, 2012

Listing all available version of a package using yum

Sometimes you want to see what version of a package is available on a repo, below is how you do it:

[humans@earth]$ sudo yum list subversion --showduplicates

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: dist1.800hosting.com

 * epel: mirror.steadfast.net

 * extras: centos.mirror.lstn.net

 * rpmforge: mirror.us.leaseweb.net

 * updates: mirror.raystedman.net

Installed Packages

subversion.x86_64                                                         1.6.11-10.el5_8                                                           installed

Available Packages

subversion.i386                                                           1.6.11-7.el5_6.4                                                          base    

subversion.x86_64                                                         1.6.11-7.el5_6.4                                                          base    

subversion.i386                                                           1.6.11-10.el5_8                                                           updates 

subversion.x86_64                                                         1.6.11-10.el5_8                                                           updates

You make that happened by using --showduplicates flag, which will show all version available for subversion, in this case :)


Thursday, November 1, 2012

Using & as replacement for matched string in sed

This is useful, if you need to add some modification to your searched string in sed, but you are using regex and you do not know what the output would be. Please see below example:

$ echo "123 123 abc abc" | sed 's/[0-9]*/(&)/'
(123) 123 abc abc

In this example, your requirement is to put parentheses around your matched/searched string. So I put '&' as the replacement for the searched string, which is any series of number between 0 to 9, and put parentheses around it.

Done :)