Tuesday, January 27, 2009

marks in vim - bookmarks

Go to a line where you want a mark and press mx - this will create a bookmark

( x can be any alphabet from a-z)

- Now navigate away from that place. If you need to get back to the earlier cursor location press "`x" (back-tick and x)

- You can set multiple "marks" in a single file and navigate using back-tick and the alphabet used to create a mark

Monday, January 26, 2009

sed : inplace replacement

It is easy to open a file in vim and do a search replace - but if the file runs into huge sizes, a regular editor would not be able to perform search and replace tasks on it efficiently. For these situation, you need a "stream" editor. Here is an example for replacing "foo" with "bar" in a file called snafu.txt


sed -i -e 's/foo/bar/g' snafu.txt


Where:

-i : Is for inplace replacement

-e: sed script to be run on the file

samba mount

Using samba to mount a windows shared folder

mount -t cifs -o username=Home\\sandeep //192.168.0.1/Shared/ /media/Shared

Where /media/Shared is the target folder where the network folder will be mounted.

Sunday, January 25, 2009

Executing a command remotely using ssh

Following command will run a shell script on a remote machine

ssh ssinghal@192.168.0.1 /tomcat/jakarta/bin/kill.sh