Wednesday, January 21, 2009


cp a b . ; \
cp c . ;

The \ indicates that both the cp are to be done on the same shell, that is they will be inclusive. But if I remove the '\' the cp commands will be exclusive. They will be executed with a break in continuity.

Searching and changing permission of files and folders

find . -name "*" -type f -exec chmod 444 {} \; -print

find . -name "*" -type d -exec chmod 555 {} \; -print

All of us have faced this problem one time or the other. We do a scp, and midway through the process scp feels knotty(naughty). The solution is rsync. To resume a partially scp-ed file we use rsync.

$> scp anjan@server1:/a/b/xyz
95% complete
Connection timed out :-(

$> rsync --partial --progress anjan@server1:/a/b/xyz


1. There are lots of other neat things you can do with block selects. Here is a way of adding a string to the end of each line, like so:

i. Press Ctrl+V and then j to extend the selection to all the lines you want.

ii. Press $. This will create a 'ragged edge' selection that extends to the right end of each line in your selection.

iii. Press A. I inserts text at the beginning of a block selection, A appends text at the end of a block selection.

iiii. Type your text and press Esc.

2. To search for ':' and remove everything in the line after that

3. All words are jumbled in one line. The must be put in separate lines...
:%s/\ /\r/g (search blanks and replace with return; globally)

4. map = j$?\/d$

To chk if the process whose pid is known is alive or dead

#! /usr/bin/perl
$exists = kill 0, $PID ;
if ($exists) {print "YES\n";} else {print "NO\n";}

No comments: