Tuesday 1 April 2014

Linux: Delete all contents of file by only a command in vi editor

To clear the contents of a file is opening. Let's try folow the following command.


Other basic useful command :
* Create a file
vi filename
* To exit vi and save changes:
         ZZ   or  :wq
* To exit vi without saving changes:
* To edit file content :
* Deleting Text :

*xdelete single character under cursor
 Nxdelete N characters, starting with character under cursor
 dwdelete the single word beginning with character under cursor
 dNwdelete N words beginning with character under cursor;
  e.g., d5w deletes 5 words
 Ddelete the remainder of the line, starting with current cursor position
*dddelete entire current line
 Ndd or dNddelete N lines, beginning with the current line;
  e.g., 5dd deletes 5 lines

* Searching Text:

 /stringsearch forward for occurrence of string in text
 ?stringsearch backward for occurrence of string in text
 nmove to next occurrence of search string
 Nmove to next occurrence of search string in opposite direction
* Screen Manipulation:

 ^fmove forward one screen
 ^bmove backward one screen
 ^dmove down (forward) one half screen
 ^umove up (back) one half screen
 ^lredraws the screen
 ^rredraws the screen, removing deleted lines

0 nhận xét:

Post a Comment