4/3/13

vi editor commands

To locate instances of particular sets of characters (or strings), use the following commands.

/string       search forward for occurrence of string in text
?string      search backward for occurrence of string in text
n               move to next occurrence of search string
N              move to next occurrence of search string in opposite direction
u               undo
U              undo all the changes

Replace
------------
:%s/oldword/newword/g
:%s/^M//g                           ----  to replace control-m characters (press ctrl-v& ctrl-m )

look for special characters:
---------------------------------
:set list

4/1/13

Unix ksh won't execute and gives error 127

If you get the error : 127 when you execute the shell script.

There might be one of these 2 issues :

1) shebong line is wrong
2) you might have copied the file from windows to unix - that will create a control/special characters at end of the line.

SOLUTION :
execute the below command

head script.ksh | cat -vet | head -1

If you see "^M" at the end of the output - then you need to remove that special character by either using "dos2unix" command or using cat command like below :

1)  cp padaddwip.ksh padaddwip.ksh.bak
     dos2unix padaddwip.ksh.bak > padaddwip.ksh

2)  cat script.ksh.bak | tr -d "\r" > script.ksh

SET SYSTEM VARIABLES - ORACLE/SQL PLUS


SET DEF[INE] {& | c | ON | OFF}

Sets the charavter used to prefix substitution variables to c.

ON or OFF controls whether SQL * Plus will scan commands for substitution variables and replace them with their values.


Example :

sql > SET DEFINE ON

        SELECT 'HELLO & ?' FROM DUAL;

       ? = WORLD   (IT WILL ASK FOR USER INPUT,HERE THE 'WORLD' IS A USER INPUT)


       OUTPUT : "HELLO WORLD"



sql > SET DEFINE OFF
        SELECT 'HELLO & ?' FROM DUAL;

        (IT WON'T ASK FOR USER INPUT AS THE DEFINE IS OFF)


        OUTPUT : "HELLO & ?"