Friday, November 2, 2012

Replace a String in Multiple Files in Linux Using Grep and Sed

grep -rl matchstring somedir/ | xargs sed -i 's/string1/string2/g'

Note: The forward slash '/' delimiter in the sed argument could also be a different delimiter (such as the pipe '|' character). The pipe delimiter might be useful when searching through a lot of html files if you didn't want to escape the forward slash, for instance. matchstring is the string you want to match, e.g., "football" string1 would ideally be the same string as matchstring, as the matchstring in the grep command will pipe only files with matchstring in them to sed. string2 is the string that replace string1.

grep -rl '' ./ | xargs sed -i 's/\/vc/\/BB/g'

Extracted from :

Friday, November 19, 2010

IE browser Renderer

All those who need a quick view of how each IE browser will render a particular site, you can use the following site and get a screen shot of a particular url.
Through this site you can get only the screen shot of a different IE browser views.

Wednesday, October 20, 2010

Installing Apache, PHP, MySQL and phpMyAdmin on Ubuntu

Installing Apache

1. Open Terminal (Application -> Accessories -> Terminal) and execute the following command:

sudo apt-get install apache2

2. When the setup is complete you can check if the Apache is working properly by pointing your browser to http://localhost. If you see the text “It works!”, it means Apache is working just fine.

3. Towards the end of the installation if you see a message like this inside Terminal, “Could not reliably determine the server’s fully qualified domain name, using for ServerName“, you can fix this by executing the following command. It will open Gedit (text editor).

gksu gedit /etc/apache2/conf.d/fqdn

4. When Gedit opens, type “ServerName localhost” inside the file and click Save. Then close the file.

Installing php5

1. Inside Terminal, execute the following command:

sudo apt-get install php5 libapache2-mod-php5

2. When setup is complete, you have to restart Apache so that php5 will work on Apache. Execute the following command in Terminal:

sudo /etc/init.d/apache2 restart

3. You can now test to see if php5 works with Apache. To do this you can create a new php file inside your /var/www/ folder. (The text in red is the filename. You can put any name.)

sudo gedit /var/www/test.php

4. The command above will open Gedit. Just type in the following php code, save and close the file:

5. Now point your browser to “http://localhost/test.php” and see if you can see the text “yoo hooo!” and a lot of information about your php5 installation. If you see that, it means your have successfully installed php5.

Installing MySQL

1. Inside Terminal, execute the following command:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

2. Towards the end of the installation you will be prompted to set your root or admin password (see pic below)

set root password

Installing phpMyAdmin

1. Inside Terminal, execute the following command:

sudo apt-get install phpmyadmin

2 During the installation you will be asked to select the webserver that would be used to run phpMyAdmin. Select Apache2 (see pic below).

choosing webserver

3. After the installation is over execute the following command to copy the phpmyadmin folder into the /var/www/ directory. (By default it is installed in /usr/share/phpmyadmin/ directory.)

sudo ln -s /usr/share/phpmyadmin/ /var/www/phpmyadmin

4. Now you can go to the phpMyAdmin login page by pointing your browser to: http://localhost/phpmyadmin/index.php

The username for MySQL and phpMyAdmin is “root”. The password will be what you set in step 2 (under installing MySQL).

That’s it! Now you’ve successfully installed Apache 2 webserver, php5, MySQL and phpMyAdmin on Ubuntu.


After installing Apache, PHP, MySQL and phpMyAdmin, you can install support for ASP.NET files in Ubuntu. Don’t worry, you will be able to work with php and aspx files on the same Apache server without any problems.

Thursday, October 7, 2010

Drupal : How to write the theme's region variables to the page.

If you're assigning your region to page.tpl.php, you don't need to worry about creating a variable for your region and assigning content to it; PHPTemplate handles this automatically. All you need to do is write the variables to the page, by editing your theme's page.tpl.php file. For each new region you've defined, include in page.tpl.php a print call. For the 'floater' region defined above, this would look like:


Of course, you'll probably want to use HTML, CSS, and possibly PHP (e.g., if tests) to get your new regions looking how you want them.

Drupal : How to define custom regions

If you want to have your own set of regions for a theme, you do this by defining a _regions() hook. In this case, your custom regions will override those defined by default in PHPTemplate.

If the theme doesn't have a template.php file in its directory, create one; otherwise use the existing template.php file. In either case, add a mytheme_regions() function to define your regions. Each region needs to have a name (a string with no spaces) and a description (the text that will show up in, for example, the block configuration pages). The following would define all the standard PHPTemplate regions except the left sidebar and, in addition, two new regions for a theme called "mytheme".

t('right sidebar'),
'content' => t('content'),
'header' => t('header'),
'footer' => t('footer'),
'floater' => t('floater'),
'inline1' => t('inline 1')

Note: Regarding the name of the function:

* use the name of your theme instead of mytheme_regions(), eg: bluemarine_regions()
* Don't use a hyphen in the name of a region; an underscore is OK.
* Also, your theme name is your base theme name not the name of your style.css directory (if you are using one). For example, box_cleanslate overrides the style.css file of the box_grey theme; therefore you should name your function box_grey_regions.

Friday, September 3, 2010

Google Transliteration

Following is the online Google Transliteration link for Sinhala Language

You can change the transliteration by changing through the language dropdown eg: Hindi

Wednesday, September 1, 2010

Office and Productivity

Windows apps    Linux apps    Description  
Windows Update, Add/Remove programs

apt-get, Aptitude, portage, rpm, urpmi, yast, yum, Synaptic

Every Linux distribution has an infrastructure to manage installed software which is quite different from Windows. For instance, all updates are handled by a single program. See package management.
Google Desktop

Beagle, Recoll, Google Desktop

Desktop Search

Alcohol 120%, Discjuggler, Easy CD Creator, Nero Burning ROM

XCDRoast, more

CD burning
7-Zip, Winzip, Winrar


File Roller,
hjsplit; command line tools

Notepad, Wordpad, TheGun, EditPlus, SciTE

Kate, BlueFish, Gedit, Joe

Text Editors
WinMerge, SyncToy

Meld, Unison, Synkron, rSync

File synchronization
Daemon Tools

mount, GMount-ISO

ISO mounting
Norton Ghost

Partition Image, g4u, Mondo, dd

Disk imaging
Norton Partition Magic

QTparted, GParted

Disk partitioning


Synchronization with Windows Mobile devices
Veritas Backup Exec, Cobian Backup

UniSon, Veritas Netbackup, more


Outlook, Thunderbird + Lightning, Sunbird
Evolution, Kontact, BALSA, Thunderbird + Lightning, Sunbird

Personal information managers
chkdsk fsck check your file system (and the hard disk beneath it) for errors
Quicken, Microsoft Money, TurboTax

GnuCash, KMyMoney, jGnash, MoneyDance, Grisbi, PLCash, CrossOver Office with Quicken, lazy8ledger

Disclib gWhere
Disk cataloging programs
Microsoft Project Manager
Imendio Planner, Kplato, MOOS Project Viewer, MrProject, RationalPlan

Project management
Access, dBase, Foxpro, Paradox
Kexi, OOBase
WinEdt, TeXnicCenter
Kile, Texmaker, LyX

Kivio, Dia
Excel, Lotus123, QuattroPro
OOCalc, Gnumeric, KSpread

OOImpress, KPresenter
OOWriter, AbiWord, KWord, LaTeX

Word Processing
Microsoft Office,
OpenOffice, KOffice, Siag Office
Office package
Filemon, Regmon

system call tracking (file monitor & others)
WinRunner xautomation automating interactive applications
Disk Size Explorer

File Light, Konqueror
Disk usage analyzers