Archive for May, 2010

On-the-fly tokenization in bash

Suppose we want to rename a number of files filename_* to othername_*. A way to do it in bash (without using specialized rename tooling) could be the following:

for i in filename_*; do mv $i othername_${i#*_}; done

The # is something called a bash shell glob. Interesting stuff that is worth a closer look at


Friday, May 28th, 2010 Uncategorized No Comments

Bash for-statements with newline delimiters / for-statements over files with spaces

The IFS environment variable is used to set delimiters for parsing lists in bash.

By default, IFS=<space><tab><newline>. This gives a problem if we want to iterate through files with a for statement if files or directories contain spaces. We can circumvent this by setting IFS=<newline>.

So, for example, if we want to iterate through all DOC files in a certain directory and remove their executable permissions, we have the following one-stop solution:

export IFS=$’\n’; for i in `find . -name “*.doc”`; do chmod -x “$i”; done

N.B.: <newline> should be set by IFS=$’\n’. Why this is the only way that works, could not be determined with a few simple web searches, so it remains a mystery.

sources: and

Friday, May 28th, 2010 Uncategorized No Comments

Adding japanese language support in ubuntu

To add japanese language support in ubuntu linux:

  • Install japanese language support from: System -> Administration -> Language support
  • Set your hot key preferences in: System -> Preferences -> IBus Preferences

To $HOME/.bashrc file add the following lines:

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
Thursday, May 13th, 2010 Uncategorized No Comments