Monday, April 16, 2012

Use Delimiter In Awk and Cut.

We can use delimiter in Awk, if you exported domain list from godaddy and you want only domain name rather than full information then you can use this command to get domain list only.
Using this:

awk -F "," '{print $1}'

Or

cut '--delimiter= ' -f1

E.g.

cat DomainDownloadList-124696210.csv | awk '{ printf " %s\n", $1 }' | awk -F "," '{print $1}' > domainlist.txt
Or
cat DomainDownloadList-124696210.csv | cut '--delimiter= ' -f1 > domainlist.txt

For word count for counting domain :
cat DomainDownloadList-124696210.csv | awk '{ printf " %s\n", $1 }' | awk -F "," '{print $1}' | wc
Or
cat DomainDownloadList-124696210.csv | cut '--delimiter= ' -f1 | wc




@ Linux Administration Blog.! 

Tuesday, April 10, 2012

Monday, April 9, 2012

How to replicate only one table from mysql database.

Install Ruby 1.9.2
Install gem rubyrep (1.2.0) using command
gem install rubyrep

Then create conf file with name   /etc/myrubyrep.conf and with following content.
-------------------------------------------------------------
RR::Initializer::run do |config|
config.left = {
:adapter  => 'mysql', # or 'pgsql'
:database => 'c11',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}

config.right = {
:adapter  => 'mysql', # or 'pgsql'
:database => 'c12',
:username => 'root',
:password => '',
:socket => '/var/lib/mysql/mysql.sock'
}

config.include_tables 'table name'  # e.g. 'email_list_subscribers' only this will replicate
#config.include_tables /^e/  # regexp matches all tables starting with e
# config.include_tables /./ # regexp matches all tables
#config.options[:auto_key_limit] = 2
end
---------------------------------------------

Using this command you can replicate only one table from database.

[root@localhost ]#  rubyrep replicate  -c /etc/myrubyrep.conf
Verifying RubyRep tables
Checking for and removing rubyrep triggers from unconfigured tables
Verifying rubyrep triggers of configured tables
Starting replication..

For only scan and sync to check status use following commands:

[root@localhost tmp]#  rubyrep scan   -c /etc/myrubyrep.conf
              email_list_subscribers 100% .........................   0

[root@localhost tmp]#  rubyrep sync  -c /etc/myrubyrep.conf
              email_list_subscribers 100% .........................   0

If modified it will change to 0 to 1.
Cool thing... Please let me know if you guys have any questions.
@ Linux Administration Blog.!