Sunday, August 26, 2012

Regular expressions vs shell patterns

Today I have discovered an important difference between regular expressions and shell patterns in a context of file searching in Linux. Their both applications may be found in a powerful utility find. Its arguments -name, -path and -wholename are interpreted as shell patterns, and -regex - as regular expressions.
The difference between regular expressions and shell patterns is in how some characters are interpreted.
Let's consider a star character (*). In shell pattern it is interpreted as match of zero or more characters. In regular expression is interpreted differently: it matches preceding character or group zero or more times.
For example, the string '*tmp' will match all strings ending with tmp by shell pattern processor, but regular expression processor won't match anything at all! In order to write an equivalent regular expression of a shell pattern we have to write '.*tmp'.
These commands are equivalent:
find . -name '*tmp'
find . -regex '.*tmp'
So be careful when writing matching expressions and know how it is interpreted.

Saturday, August 11, 2012

How to set up keyboard layout changing in xfce

One may change keyboard layout in xcfe with the following command:

setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,de,it

Moreover most users may want to do it only once on login. For this reason the command has to be saved in whether ~/.profile or ~/.bash_profile or ~/.bash_login if one of the two latter files exist. 

Thursday, August 9, 2012

How to enable vim syntax highlighting in Ubuntu 12.04

There are much information on the internet, about how to enable syntax highlighting in Ubuntu.
Some of them advice using the command :syntax=on, another saying about installing vim-full.
These advises are valid for earlier versions of Ubuntu, but not for the 12.04.
So in order to enable syntax highlighting one has to install vim-gnome and it will be enabled automatically:
sudo apt-get install vim-gnome