Tuesday, August 14, 2007

Vi Search and Replace

Change to normal mode with .

Search (Wraped around at end of file):

Search STRING forward : / STRING.
Search STRING backward: ? STRING.

Repeat search: n
Repeat search in opposite direction: N (SHIFT-n)


Replace: Same as with sed, Replace OLD with NEW:


First occurrence on current line: :s/OLD/NEW

Globally (all) on current line: :s/OLD/NEW/g

Between two lines #,#: :#,#s/OLD/NEW/g

Every occurrence in file: :%s/OLD/NEW/g


copied from http://www.felixgers.de/teaching/emacs/vi_search_replace.html

Friday, August 10, 2007

ls to twiki text

The following is useful when writing twiki documentation on a load of files in a directory:

ls ../PHEDEX/Toolkit/Transfer/|awk '{for (i = 1; i <= 1; i++) print "---++ " $i}'

It will print each file in the directory as a heading for the twiki page. Change as appropriate, for example:

ls ../PHEDEX/Toolkit/Transfer/|awk '{for (i = 1; i <= 1; i++) print " i " $i}'
ls ../PHEDEX/Toolkit/Transfer/|awk '{for (i = 1; i <= 1; i++) print " * " $i}'


makes lists.

Thursday, August 09, 2007

Wednesday, August 01, 2007

Delete files from CASTOR

castordelpath = /castor/ads.rl.ac.uk/prod/cms/store/LoadTest07
for i in `nsls $castordelpath`;
do srm-advisory-delete srm://ralsrmf.rl.ac.uk:8443/srm/managerv1?SFN=$castordelpath/$i;
stager_rm -M $castordelpath/$i;
nsrm $castordelpath/$i;
done