I had a requirement where I needed to extract the third level sub domain name from a set of hostnames. "cut" alone was not enough to do the job as the hostnames where at different levels.
What I had was a set of hostnames like this ( This is not the real one that I worked on :P )
safeer@enjoyfast-lx:~/temp$ cat hosts.txt
www.safeer.in
dev.safeer.in
www.dev.safeer.in
mail.dev.safeer.in
mail.safeer.in
svn.dev.safeer.in
pop.mail.safeer.in
smtp.mail.safeer.in
blog.safeer.in
techlog.safeer.in
vm1.alpaha.dev.safeer.in
vm2.alpaha.dev.safeer.in
As you can see the hostnames are at different subdomain levels. So the only way is to extract the third field from right of the hostname. For this I made use of the "rev" command - which basically reverses a string and extracted the third filed as follows.
safeer@enjoyfast-lx:~/temp$ cat hosts.txt |rev|cut -d '.' -f3|rev
www
dev
dev
dev
mail
dev
mail
mail
blog
techlog
dev
dev
Did a sort to eliminate the duplicate entries. That did the trick and I got the result I needed
safeer@enjoyfast-lx:~/temp$ cat hosts.txt |rev|cut -d '.' -f3|rev|sort -u
blog
dev
mail
techlog
www
Tuesday, November 18, 2008
Sunday, November 16, 2008
Changing Your Wordpress URL
Well, I was thinking about changing my blog URL to a nicer one. Added the new DNS sub domain and pointed it to my server. Created a new entry inapache configuration and moved all the files to the new document root( optional - only if you want to move it into a new location). This is enough to change the URL for a normal website. But for a CMS/blogging software that stores all the data and meta data in databases, this is not enough.
For wordpress, there are two database entries that affects the url. Both resides in the table wp_options. So need to update them as well.
mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='home';
mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='siteurl';
That is it. All set now.
For wordpress, there are two database entries that affects the url. Both resides in the table wp_options. So need to update them as well.
mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='home';
mysql> update wp_options set optionvalue='http://techlog.safeer.in' where option_name='siteurl';
That is it. All set now.
Labels:
Wordpress
Wednesday, November 12, 2008
Ubuntu Display Tips
Found out a couple of useful shortcuts/tricks while working on my Ubuntu laptop (8.04/Hardy Heron).
Press "Windows" key and move mouse scroll button downwards to get an enlarged display of your desktop. Move the cursor to the borders of the screen to travel from side to side/top to bottom of the enlarged screen. To zoom out scroll in the reverse direction
Place cursor on any active window/panel, press "Alt" and move scroll button downwards to make that window/panel transparent. To turn it back to opaque scroll in the reverse direction.
My "Visual Effects" setting is set to Normal in Appearance Preferences. (System->Preferences->Appearance->Visual Effects)
Press "Windows" key and move mouse scroll button downwards to get an enlarged display of your desktop. Move the cursor to the borders of the screen to travel from side to side/top to bottom of the enlarged screen. To zoom out scroll in the reverse direction
Place cursor on any active window/panel, press "Alt" and move scroll button downwards to make that window/panel transparent. To turn it back to opaque scroll in the reverse direction.
My "Visual Effects" setting is set to Normal in Appearance Preferences. (System->Preferences->Appearance->Visual Effects)
Subscribe to:
Comments (Atom)