better unix life2

If you need to work on cluster, is nice to have syncronized terminals to send the same commands in parallel.

Is it also doungerous, so do some test before sending a bunch of vi commands!

On Unix, a cheap and fast solution is Kde “konsole” which has such option.

Look under “View/Send input to all Sessions” menu and try it out.  I was happpy with version 1.6.6 of konsole.
I am not a fan of “xterm variants”, but konsole looks great.

better unix life

This entry is part 1 of 2 in the series Unix swissknife

File mass replace

Use the sed -i command

sed -i.BAK 's|foo|bar|g' files # -i does in-place replacement
perl -pi.bak -e 's|foo|bar|g' files                # or
perl -pi.bak -e 's|foo|bar|g' `find /pathname -name "filespec"`

 

Perl is the preferred way, but on some production system you must use the old good sed. For some tips on sed take a look to its faq.

 

Another very powerful command is xargs. Xargs is a rapid  way to process files containing spaces, using  a  combo with find:

find . -print0 -type f   | xargs -0 ls  | grep " "

Xargs is normally fastest then relaying on backtick substitution. For instance:

ls $(find . -type f)

is  slower then

find . -type f | xargs ls

because this second form create two process which works at the same time, using the unix pipe.