Friday, August 24, 2007

date format

date +%F\@%H%M

will display

2007-08-24@1439

vim keystrokes

1. Shift-k displays man page
place the cursor on a unix command word and press Shift-k
the man page for the command will be displayed

Thursday, August 23, 2007

file diff using vim

starting diff mode

vimdiff file1 file2 or vim -d file1 file2


while already in vim you can start diff mode in three ways.

:diffsplit {filename} - open a new window on the file {filename}
:diffthis - make the current window part of the diff windows
:diffpatch {patchfile} - use the current buffer, patch it with the diff found in {patchfile} and open a bufer on the result



jumping to diffs

[c - jump backwards to the previous start of a change
]c - jump forwards to the next start of a change



diff copying

:[range]diffg[et] - modify the current buffer to undo difference with another buffer
:[range]diffpu[t] - modify another buffer to undo difference with the current buffer
do - same as ":diffget" without argument or range. the "o" stands for "obtain"
dp - same as ":diffput" without the argument or range

when no [range] is given, the diff at the cursor position or just above it is affectes.

Wednesday, August 22, 2007

find and overwrite a file

i had a need to find all files of a certain name, 'file1.file' and a certain size, greater than 20k, and overwrite every occurence with a different file 'file2.file'.

find ./ -type f -iname 'file1.file' -size +20k -exec cp ~/trunk/file2.file '{}' \;
./ == start find from the current directory
-type f == search for files
-iname 'file1.file' == insensitive case of the file named file1.file
-size +20k == search for files 20k in size or greater
-exec cp ~/trunk/file2.file '{}' \; == for each file found in the find, copy ~/trunk/file2.file and overwrite

Tuesday, August 21, 2007

initial postgres login

i recently installed postgres 8.1 on my debian system using aptitude. following are the steps i used to create a new database or user.

1. su to super user
2. su to postgres user
3. create a new database or user

for more follow http://blog.revsys.com/2007/05/common_postgres.html