Tuesday, September 16, 2008

Bash : concatenate strings in bash

The problem -

You have $yr=2008
You want to obtain something like 2008_data.csv etc

$yr_data.csv does not work

The solution - Use curly braces to separate variables from strings
like this

${yr}_data.csv

Thursday, September 11, 2008

Linux : setting up hostname

Here's how you can set hostname of your linux machine

Become root, save hostname in /etc/hostname and tell the hostname
command to read the name from the file.
Here are the commands to do the same

% su
% echo your_hostname > /etc/hostname
% hostname -F /etc/hostname

However, on next reboot, hostname will be lost.

On Red Hat / centOS, edit HOSTNAME= entry of the file
/etc/sysconfig/network

This sets up the hostname permanently.