Saturday, March 15, 2014

MODIFY THE FILE BY USING VI COMMAND

modify the file by using ' vi ' command

create a file  by using cat command
ex:- [root@loaclhost~]# cat > line
hi
how are you
ctrl + d (save & quit)

[root@localhost ~]# vi line


command options

i - inserts the text at current cursor position
I - insert the text at beginning of line
a - append the text after current cursor
A - appends the text at the end of line
o - inserts a line below current cursor
O- inserts a line above current cursor
r - replace a single char at current cursor

exit the file (shift + esc + : )
:q     - quit without saving
:q!    - quit forcefully without saving
:w     - save
:wq   - save & quit
: wq! - save & quit forcefully
:x      - save & quit

command lines copy, delete,cut,past

dd - delete a line
yy - copy a line
p  - put
u - undo
ctrl + r - redo
g - move cursor to last line of file
xhift+zz - save & quit

No comments:

Post a Comment