Basic Unix Vi editor command

Unix Vi editor command keys:


































Exit, saving changes

Enter ex mode

End of insert

Execute ex command

Shell command

Show filename/size

Forward one screen

Back one screen

Forward half screen

Backward half screen

Go to line <x>

Search forward for <x>

Search backward for <x>

Repeat last search

Reverse last search

Next section/function

Previous section/function

Find matching () { or }

Redraw screen

Refresh screen

Current line at top

Current line at bottom

Scroll down one line

Scroll up one line

revious context

Home window line

Last window line

Middle window line

Next line

Cursor movement:


Beginning of line

End of line

Find <x> forward

Find <x> backward




































Up to <x> forward

Back up to <x>

Go to column <x>

Forward one word

Back one word

End of word

Erase last character

Erase last word


Toggle character case

Append after

Insert before

Append at end of line

Open line below

Open line above

Replace character

Replace characters


Delete line


Yank lines to buffer

Change rest of line

Delete rest of line

Substitute character

Substitute lines

Join lines

Delete after

Delete before

Yank current line

Put back lines

Put before

Shift line left

Shift line right

Undo last change

Restore current line

File Options:

sh      Invoke shell

vi      Vi mode

wq      Write and quit

w <f>   Write file <f>

w! <f>  Overwrite file <f>

Ex mode commands:



r <f>

set <x>

set no<v>

set all


Quit, discard changes

Read in file <f>

Enable option

Disable option

Show all options


Sample Example on How To Extract Worksheet IDs of a Workbook through Discoverer Desktop via the d51wkdmp utility

Sample Example on How To Extract Worksheet IDs of a Workbook through Discoverer Desktop via the d51wkdmp utility


d51wkdmp.exe <Workbook_Name> <Output_File> DB <Connect_String>  <Eul_Schema> -f

(1) Log into your pc where Discoverer Desktop is installed.

(2) Find out the exact location of the ‘d51wkdmp.exe’ file.

(3) Click <Start> <Run> and enter ‘cmd’ to go to command prompt.

(4) Enter and run the following at the prompt, for example:
C:\> d:\oracle\BI_1012\bin\d51wkdmp.exe “Employee By Dept” Outfile2.txt DB scott/tiger@TestDB1 Eul_owner -f

WHERE there are 3 Worksheets in this example.

RESULT:  Outfile2.txt

EUL Item Reference
IoId = 16
Id = 100671
Identifier = DEPTNO
Name = Deptno
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 24
Id = 100664
Identifier = EMPNO
Name = Empno
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 32
Id = 100665
Identifier = ENAME
Name = Ename
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 40
Id = 100666
Identifier = JOB
Name = Job
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 48
Id = 100667
Identifier = MGR
Name = Mgr
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 56
Id = 100668
Identifier = HIREDATE
Name = Hiredate
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Item Reference
IoId = 64
Id = 100669
Identifier = SAL
Name = Sal
Folder Identifier = EMP_1
Folder Name = Emp 1
*** Found in EUL by id ***
EUL Private Item
Id = -32
Name = Sal SUM
Identifier = 7
Desc =
DataType = 2
Placement = 1
Hidden = 0
IsACalc = 0
IOFormula = [1,1]([6,64])
DisplayFormula = SUM(Sal)
Query Request QR1
Distinct = 1
Axis Item Usage – Name = EUL Item – Emp 1.Empno
Axis Item Usage – Name = EUL Item – Emp 1.Ename
Axis Item Usage – Name = EUL Item – Emp 1.Job
Axis Item Usage – Name = EUL Item – Emp 1.Mgr
Axis Item Usage – Name = EUL Item – Emp 1.Hiredat
Axis Item Usage – Name = EUL Item – Emp 1.Deptno
Measure Item Usage – Name = Calculation – Sal SUM
Identifier = 68

Sheet Number 1
Sheet Name = Sheet 1
Sheet Unique Name = Workbook 11503332070
Sheet Identifier = 1
Query(s) used =
Query 1
Items :-
EUL Item – Emp 1.Empno
EUL Item – Emp 1.Ename
EUL Item – Emp 1.Job
EUL Item – Emp 1.Mgr
EUL Item – Emp 1.Hiredate
EUL Item – Emp 1.Deptno
Calculation – Sal SUM



Using Images in Oracle HRMS

Hello Friends, Lets learn something in Oracle HRMS. Oracle Human resources has a table called PER_IMAGES. This table stores employee pictures in RAW format. If you want to mass upload the pictures of all employees in this table, you can have a hard time. we were facing a similar issue, and here is the approach i used to bulk upload (or mass upload) employee pictures to PER_IMAGES table in Oracle Human resources system using SQL Loader.

First, let’s see how the table looks:

SQL> desc per_images

Name                            Null?    Type
——————————- ——– —-
IMAGE_ID                        NOT NULL NUMBER(15)
IMAGE                           NOT NULL LONG RAW
PARENT_ID                       NOT NULL NUMBER(15)
TABLE_NAME                      NOT NULL VARCHAR2(30)
IMAGE_ID   – Next value in sequence
IMAGE      – Binary Image

To load a binary image in this table, we have to first create a control file, which will look something like this:

options (bindsize 400000)
load data
infile photo.bmp “fix 60999”
concatenate 3
into table PER_IMAGES
(image_id constant 1, image raw(33532), parent_id constant 1253,
table_name constant “PER_PEOPLE_F”)
Some important facts now: Size of picture in this example is 33532 bytes. Bindsize must always be larger than the filesize. And, most importantly, only 64k can be loaded at one time, so we have divided the file size into equal portions < 64k. Here are the shell scripts, and ctl files i am using:

   echo enter file name
   read fname
 while read line
  value=`head -n $x $fname | tail -n 1`
           echo $x $value;
                sh $x $value
                x=`expr $x + 1`
   echo “****$value”;
What the above script called mainscript does is that it read the file that contain employee id and picture file name.For each employee, it than calls another shell script called, and increments the id. This id we will be using in the ctl file.

filesize=`ls -l $3 | awk ‘{print $5}’`
fixsize=`expr $filesize`

if [ $filesize -gt 65536 ]; then
   echo “Filesize more than 6 k. breaking up…”
    if [ $filesize -gt 131072 ]; then
    if [ $filesize -gt 196608 ]; then
    if [ $filesize -gt 262144 ]; then
   echo “Breaking into parts :”$concno
   fixsize=`expr $filesize / $concno`  

echo $1 $2 $3 $4 “fixsize” $fixsize “filesize” $filesize “conc” $concno >> fileload.log

echo “Creating ctl file for dataload now”
echo “options (bindsize=400000)” >> loadpics.ctl
echo “load data” >> loadpics.ctl
echo “infile $3″ \”fix $fixsize\”>> loadpics.ctl
echo “append” >> loadpics.ctl
echo “concatenate “$concno >> loadpics.ctl
echo “into table PER_IMAGES” >> loadpics.ctl
echo “(image_id constant $1,” >> loadpics.ctl
echo “image raw($filesize),” >> loadpics.ctl
echo “parent_id constant $2,” >> loadpics.ctl
echo “table_name constant \”PER_PEOPLE_F\”)” >> loadpics.ctl
echo “” >> loadpics.ctl

sqlldr apps/<appspwd> control=loadpics.ctl log=picsload.log

mv loadpics.ctl loadpicslast.ctl


Above script is pretty simple, isn’t it? Well what we are doing is reading the file size, and creating
a ctl file with the information gathered. Then we are calling SQLLDR to upload the picture using this CTL file.

Hope this helps you! Thanks you …. Shivmohan Purohit

Article Courtesy:

UNIX / Shell Programming Basic – Beginner Questions Answers



What is $*?

Its mainly used for showing up all params. This show all parameter values passed in shell script


What does $# stand for?

# will return the number of parameters that are passed as the command-line arguments.


What does $? Return?

$? will return exit status of command .0 if command gets successfully executed ,non-zero if command failed.


What are Different types of shells?

sh : the oldest shell 
csh : C shell 
ksh : Korn Shell 
bash : bourne again shell



How do you read arguments in a shell program – $1, $2?

Shell script accepts parameters in following format… 
$1 would be the first command line argument, $2 the second, and so on 
$0 is the name of the script or function

If your script has more than 9 params then accept in following way… 
${12} : 12th param 
${18} : 18th param


What are the different kinds of loops available in shell script?

for, if, while, case


What is the difference between a shell variable that is exported and the one that is not exported?

The Shell variable which is exported would available to all the programs outside the Shell also. And the shell variable which is not exported, would available for that shell or for the shell program only, in which the variable is declared.


Export LANG=C 
will make the variable LANG the
global variable, put it into the global environment. All other processes can use it. 
will change the value only in the current script. 



If you have a string “one two three”, which shell command would you use to extract the strings?

echo $string | cut -d” ” -f1 
echo $string | cut -d” ” -f2 
echo $string | cut -d” ” -f3 


How will you list only the empty lines in a file (using grep)?

grep “^$” filename.txt


How would you get the character positions 10-20 from a text file?

cat filename.txt | cut -c 10-20


cut -c10-20 <filename.txt>


How would you replace the n character in a file with some xyz?

sed ‘s/n/xyz/g’ filename > new_filename


We can replace n characters by using the following command:
where 1 shows that the search string will start searching patterns from first line of the file.
           ‘.’ for any character.

            g for global replacemet.



What is the difference between a ‘thread’ and a ‘process’?

A process is a collection of virtual memory space, code, data, and system resources. A thread is code that is to be serially executed within a process. A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread

Thread – is stream of executable code within process. They are light weight process. All thread with in a process  share process instruction,code & data segment,open file descriptor,signal handler,userID and GroupID. Thread has its own set of register including program counter,stack pointer 


What is this line in the shell script do ?#!/bin/ksh?

To invoke the shell indirectly this line is added as the first line in the file.This particular line invokes korn shell



What is use of “cut” command? Give some examples.

Cut – Utility used to cut/Strip out the required data/text from the source.

Cut can be used in three modes,

  Stripping by Character

     cut -c 1-3

  Striping by Byte length

     cut -b -1-72

Stripping by delimiter and fields.

     cut -d “|” -f1


-d “|” -> Delimiter used in input text to separate columns

-f1 -> Field/Column number  

While processing huge input files, Cut’s performance is far better than awk



thanks – shivmohan purohit