User Tools

Site Tools


shell

This is an old revision of the document!


Shell tips and tricks

Environment Modules

The environment modules package can be used to dynamically configure your shell environment for different software packages. If you have two versions of the R statistics package you could easily switch between the two using the module command:

$ type -a R
R is /usr/bin/R
$ module load R/2.11.0
$ type -a R
R is /paracel/paracel/biosoft/R/2.11.0/bin/R
R is /usr/bin/R

Searching for a string in multiple files

Ever need to search through all your files for a certain word or phrase? You probably know about the grep command, but did you know it's recursive?

Here's an example. In this case we're searching for the word "modules":

grep -r "modules" .

By using the "-r" switch, we're telling grep to scan files in the current directory and all sub-directories. It will return a list of files the string was found in, and a copy of the line it was found on.

If you'd rather just get the file names and skip the rest of the output, use the "-l" switch, like so:

grep -lr "modules" .

Here's another tip: grep also supports regular expressions, so matching against a wildcard pattern is easy:

grep -lr "mod.*" .

That command will print a list of files containing any word starting with "mod".

You can also use grep to search for multiple words:

grep -r "drupal\|joomla\|wordpress" .

And, of course, grep supports file name wildcards in the standard unix fashion. In this example, grep will search only file names starting with "log":

grep -lr "mod.*" ./log*

Bluetooth

sudo apt-get install obextool gnome-vfs-obexftp blueman

Statically linking executable

 ./configure LDFLAGS=-static 
 make LDFLAGS=-all-static 
shell.1276258511.txt.gz · Last modified: by 172.26.14.218